-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ParseObject attributes of the ParseObject in afterSave/beforeSave triggers aren't valid for using in queries. #2000
Comments
I think I am seeing something related but a different error - I'm getting {"code":119,"message":"Permission denied for this action."} I have an Account, which has an owning Customer. In the afterSave I want to update the count of Accounts in the Customer and add the Account to the Customer's array of Accounts. My afterSave for Account is: Parse.Cloud.afterSave("Account", function(request) {
//Parse.Cloud.useMasterKey();
console.log("request.object id " + request.object.id);
if (request.object.existed()) {
console.log("account existed, returning");
return;
}
var sessionToken = request.user.getSessionToken()
console.log("request.user.getSessionToken " + sessionToken);
var customer = request.object.get("customer");
console.log("pre-fetch got customer id " + customer.id);
return customer.fetch({useMasterKey: true},{sessionToken: sessionToken}).then(function(customer) {
console.log("got customer id " + customer.id);
console.log("got customer " + customer.name);
console.log("customer number of accounts - " + customer.numberOfAccounts);
customer.increment('numberOfAccounts',1);
customer.addUnique("accountsArray",request.object);
return customer.save({useMasterKey: true},{sessionToken: sessionToken});
}).then(function() {
console.log("afterSave account SUCCESS");
},function(error) {
console.log("afterSave Account: FAIL" + JSON.stringify(error));
logger.log("afterSave Account: FAIL" + JSON.stringify(error));
});
}); The logs for these show at even after fetching, the Customer name and numberOfAccounts are undefined.
Both Customer and Account are only accessible to a role called Admin. The calling user (me) is a member of that Role. |
In my code above, rather than fetching the Customer, I've tried doing a query like this: query.equalTo("objectId", customer.id); The Customer that is returned is in the same state as above - members are undefined. |
After doing some debugging in the Parse Server code that's returning my error, I think I'm getting that permissions fail because that class doesn't have "addField" permission. However, this code is not adding a field - I suspect Parse Server thinks that because the object is improperly fetched and its fields are undefined. |
We're closing this issue due to inactivity. If this is a bug you care about that is not getting attention, consider opening a pull request with a fix. |
But the inactivity's from your side! In that case surely it should stay open? |
@zingano did you solve the ParseError 119? thrown in your afterSave function? |
In an afterSave trigger I get an attribute that is ParseObject
request.object.get('pointerToOtherParseObject').
I then use that object in a query and get this error:You cannot use [object Object] as a query parameter.
If I convert the object that was an attribute to the triggered object to a new ParseObject everything works as normal.
On the Parse.com hosted service I can use these attributes for performing a query.
Steps to reproduce
Please include a detailed list of steps that reproduce the issue. Include curl commands when applicable.
Trigger Setup
Environment Setup
Hitting the trigger
Expected Results
THe DailyPostCommentCount to increment 'count' counter.
Actual Outcome
If I convert the object to new ParseObject of the correct class everything works as normal:
Environment Setup
Server
Same result when tried on Heroku
Database
Logs/Trace
You can turn on additional logging by configuring VERBOSE=1 in your environment.
The text was updated successfully, but these errors were encountered: