Meteor: Can't update fields with $set - meteor

I'm learning Meteor. So far, I've been able to initialize properties on User.profile with the following:
Meteor.users.update(Meteor.userId(),{$set:cardObject});
I'd like to update those properties but when I use the same technique I get this:
errorClass {error: 403, reason: "Access denied", details: undefined, message: "Access denied [403]", errorType: "Meteor.Error"…}
It will let me $unset the properties though:
Meteor.users.update(Meteor.userId(),{$unset: cardObject});
This is strange to me. I can delete properties but not modify them.
Any ideas?

I don't have the full codebase, so I'm guessing, but based on your code snippet, it might be because cardObject doesn't complete the $set commmand properly. a typical $set command looks like this:
...{"$set" : {"key": "value"}}...
so, it may depend on what is in your cardObject.
Whereas your $unset will work just fine because you only need the key to perform an unset.

Related

Preact "ReferenceError: window is not defined"

I'm trying to use a web API in my Preact app and can't seem to find a workaround for this error
Build [=================== ] 93% (10.2s) after chunk asset optimization
ReferenceError: window is not defined
method: UqHU
Stack:
{
"fileName": "D:\\preact-app\\build\\ssr-build\\ssr-bundle.js",
"lineNumber": 1,
"functionName": "Object.UqHU",
"methodName": "UqHU",
"columnNumber": 93549,
"native": false
}
This is most likely caused by using DOM or Web APIs.
Pre-render runs in node and has no access to globals available in browsers.
Consider wrapping code producing error in: "if (typeof window !== "undefined") { ... }"
Alternatively use "preact build --no-prerender" to disable prerendering.
See https://github.com/preactjs/preact-cli#pre-rendering for further information.
I have tried "if (typeof window !== "undefined")" but still getting the same error. Commenting out the code or using --no-prerender solves it
The problem came from the import of axios, which depends on the "form-data" library and is not compatible with Preact prerendering as far as I understand. I chose to use fetch instead of axios to fix this but rschristian gives more solutions in this post: https://github.com/preactjs/preact-cli/discussions/1784
preact-cli prerenders your app in Node, where browser globals (such as window) do not exist.
If you've added a window check but are still getting the same error, that means you have other code also trying to access window. Each offending use will need to be wrapped in a window check if you want to prerender your app.
If you want to make a discussion on the preact-cli repo and provide your app, I can try to take a look.
Edit: The issue is in an upstream dependency of axios, form-data. This has an unsound browser vs Node check, meaning any use of axios at all will throw an error. The simplest solution would be to patch form-data/lib/browser.js with the following snippet:
module.exports = typeof self == 'object' ? self.FormData : typeof window !='undefined' ? window.FormData : undefined;
https://github.com/preactjs/preact-cli/discussions/1784

Error: 5 NOT_FOUND: Resource not found (resource=blockchain-transactions)

I’ve got an angular/node.js application that uses firebase functions and blockchain in the back end.
I’m getting an error when it tries to add an object to the blockchain:
Error: 5 NOT_FOUND: Resource not found (resource=blockchain-transactions)
This is coming from this line here:
const pubsub = new PubSub();
pubsub.topic(‘blockchain-transactions').publisher().publish(signedBlockTransaction);
The call to publish(signedBlockTransaction) is throwing the error.
All I can understand about this error is that it’s looking for a resource called ‘blockchain-transaction’ and it can’t find it. But beyond this, I’m not sure why it can’t find it or how to fix it (I didn’t write the code).
One thing that may be affecting it is the following:
I was dealing with a different error which I managed to get by but I don’t know if I did it the right way. The error was:
Cannot read property ‘privatekey’ of undefined
…when trying to execute this line:
functions.config().blockchain.privatekey
It turns out .runtimeconfig.json was empty, literally only containing {}
So in an attempt to give it a private key, I went to my file id_rsa which contain a private key for something or other (I think github) and added it like so:
{
"blockchain": {
“privatekey": *** my private key ***
}
}
That got me past the first error, but I understood the private key I gave it probably isn’t the one it’s looking for.
So my question is: is the error I’m encountering now a consequence of the wrong private key? If not, what is the cause of the error, and how do I fix it?
Thanks.

Deploying Microsoft.Maps/account

I have used an ARM Template to deploy a Microsoft.Maps/account resource to Azure.
That was successful:
Resource Microsoft.Maps/accounts 'nzmoebasedemo0000bt' provisioning status is succeeded
I'd like to retrieve the Primary key generated, within the ARM template, in order to persist it to a KeyVault.
I looked in https://resource.azure.com but the Maps/account provider was not listed, so could find no hint as to what property to read.
I tried:
[listKeys(resourceId('Microsoft.Maps/account', 'parameters('keyVaultVaultSecretMapsAccountResourceName')'), providers('Microsoft.Maps', 'account').apiVersions[0]).keys[0].value]"
Abd got back:
#{parameters=; status=Trial run failed. ; outputs=; provisionStateSucceeded=False; deploymentOutput=; errorCode=InvalidTemplate; errorMessage=Deployment template validation failed: 'The template resource 'azure.arm.base.keyVault.vault.secret' at line '168' and column '9' is not valid: Unable to evaluate template language function 'providers': function requires the second argument to be a multi-segmented resource type excluding the resource provider namespace. Invalid function argument 'account'. Please see https://aka.ms/arm-template-expressions/#providers for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'.}
Which in this case...seems incorrect.
What am I not seeing/getting?
Thanks!
Edit:
As per suggestion given, the following did pass a test run.
"[listKeys(resourceId('Microsoft.Maps/account', parameters('keyVaultVaultSecretMapsAccountResourceName')), '2018-05-01').keys[0].value]"
But when actually run, got the following:
1:02:35 AM - Resource Microsoft.Maps/account 'nzmoebasedemo0000bt' failed with message '{
"error": {
"code": "InvalidResourceType",
"message": "The resource type could not be found in the namespace 'Microsoft.Maps' for api version '2018-05-01'."
}
}'
Edit again:
As per guidance given in the comments, the following works! (after correcting api version, spelling mistake, and using 'primaryKey' property:
"[listKeys(resourceId('Microsoft.Maps/accounts', parameters('keyVaultVaultSecretMapsAccountsResourceName')), '2018-05-01').primaryKey]"
So the problem was due to a typo, the provider\resource is Microsoft.Maps/accounts

Exception from Tracker recompute function

I have a template helper that access a collection in my app., but I have turned off reactivity:
Template.homeBoxGroupsTpl.helpers({
boxes: function () {
return Boxes.find({},
{
sort: {
order: 1
},
reactive: (Session.get("homeCanvasTplReactive") || false)
}
);
}
});
After I insert a new element on my page, that in turn updates the collection, Meteor will throw an error in the browser console:
Error: Exception from Tracker recompute function: reporters.js?1429904535194:67
Error: Error: Bad index in range.getMember: 16
at DOMRange.getMember (http://tidee-vm/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:586:11)
at http://tidee-vm/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2727:45
at Object.Tracker.nonreactive (http://tidee-vm/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12)
at Object.Blaze.Each.eachView.onViewCreated.eachView.stopHandle.ObserveSequence.observe.changedAt (http://tidee-vm/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2721:17)
at http://tidee-vm/packages/observe-sequence.js?0532a9dd76dd78f543eb4d79a1e429df186d8bde:313:21
at Function._.each._.forEach (http://tidee-vm/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:164:22)
at diffArray (http://tidee-vm/packages/observe-sequence.js?0532a9dd76dd78f543eb4d79a1e429df186d8bde:299:5)
at http://tidee-vm/packages/observe-sequence.js?0532a9dd76dd78f543eb4d79a1e429df186d8bde:147:9
at Object.Tracker.nonreactive (http://tidee-vm/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12)
at http://tidee-vm/packages/observe-sequence.js?0532a9dd76dd78f543eb4d79a1e429df186d8bde:121:15
Any ideas how to debug this, or is it a Meteor issue?
Meteor's error messages are horrible in all browsers but Chrome, because Meteor expects stack traces to include the error messages, but this is only done by Chrome. I hate to say this, but you'll probably have to use Chrome when debugging a Meteor app. :(
I do not have the solution, but I too encountered the same error, and was able to solve for my case, so posting it, hoping it helps you debug the issue (although this hardly seems to be of any help). The cause was use of .length. I had a large array (name of array: data), and to make it short (decrease length of arrray), I was assigning data.length = 5, which was somehow causing the error, and meteor helper did not work as expected. Removing that line worked for me, and I accomplished shortening of array by a for loop, and storing first five elements in a different variable.
I have faced similar problem too :(
I was able to resolve it by giving unique names to Tempaltes, its corresponding Helpersobject's methods in .js file and Mongo DataBase object(s) names.
Hope it might work for you too :)
For me, I was getting this error from it saying ReactionProduct.selectedVariant() is null on one of Meteor's cycles.
I just handled the null case with:
if (ReactionProduct.selectedVariant() === null) {
return;
}
and it's working out for me.

How to create a User in Alfresco?

I tried creating a user. But when I tried, it displayed the following error:
Failed to create the user: 05190030 Wrapped Exception (with status template): 05192817 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/repository/person/people.‌​post.json.js': Non-unique path:found : /app:company_home/app:user_homes 0." I am new to Alfresco. Can anyone help me?
This pretty much sounds like you try to create a user which already exists (username property is unique).
As stated in my comment to your other question, it's a known issue when you move, delete or rename User Homes.

Resources