-
-
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
Cloud Code object.save() results in 'object not found' with very strange PUT command #2098
Comments
Can I ask you to try something? Can you replace the following code
with
Does that work? |
@araskin Thanks for the suggestion. I tried it, but it does not work as the object is not actually fetched. As far as I know, 'get' on Parse objects is for retrieving properties... not getting the actual object. Interestingly, the final receipt.save() still produces the same resulting REST call |
@MobileVet I appoglize Rob. You are right 'get' is for getting property so what I should have said was this:
|
@araskin The query works... but still get the same error when I attempt to save it after changing some values. Pretty sure the fetch() works as well. Did some 'take it out, put each line back in one by one' debugging and narrowed it down to the else clause that adds other object types to the receipt:
I don't understand why this works fine on NEW objects, but somehow changes the PUT call when done on an object that exists. |
Can you debug it? Make sure the value you are setting is what you are expecting it to be? Sent from my BlackBerry - the most secure mobile device From:[email protected]:June 19, 2016 8:21 PMTo:[email protected]:[email protected]:[email protected]; [email protected]:Re: [ParsePlatform/parse-server] Cloud Code object.save() results in 'object not found' with very strange PUT command (#2098) @araskin The query works... but still get the same error when I attempt to save it after changing some values. Pretty sure the fetch() works as well. Did some 'take it out, put each line back in one by one' debugging and narrowed it down to the else clause that adds other object types to the receipt:
I don't understand why this works fine on NEW objects, but somehow changes the PUT call when done on an object that exists. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread. |
@araskin Yep... console log shows it is valid... and it works on new receipts. Verbose log shows the valid object (I think, maybe I am missing something). See the REST JSON below. verbose: PUT /parse/classes/Receipt/[object%20Object] { 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.5 (NodeJS 5.10.1)', |
Obviously the issue is in the PUT URL but you all ready know that. The object not found error is because the objectId that it is expecting is invalid. So I guess it has something to do with the way you are instantiating the object. I would start by implementing https://github.com/node-inspector/node-inspector and then debugging the cloud function. Sent from my BlackBerry - the most secure mobile device From:[email protected]:June 19, 2016 8:37 PMTo:[email protected]:[email protected]:[email protected]; [email protected]:Re: [ParsePlatform/parse-server] Cloud Code object.save() results in 'object not found' with very strange PUT command (#2098) @araskin Yep... console log shows it is valid... and it works on new receipts. Verbose log shows the valid object (I think, maybe I am missing something). See the REST JSON below. verbose: PUT /parse/classes/Receipt/[object%20Object] { 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.5 (NodeJS 5.10.1)', —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread. |
It seems that something is wrong with your logic in that code, and that may be better suited for stack overflow. Make sure all the calls setting objectId on an object are done with a proper string. As for the solution, because you don't delete the objectId key from the params, this falls into the else, creating a new object. you else should be
|
@flovilmart Thanks for looking at this. I have submitted it to SO and just added a bounty. I don't think this is a code logic issue... the object is appropriately fetched and the values included in the PUT look correct, except for the call itself. I would expect to see Instead I see Additionally, this only happens if I include the section for adding in object pointers. If I only include raw values (string, num) everything works fine. |
Did you try doing
I'm 100% confident that at one point, you're setting an objectId on an object, and that objectId is not a string...
|
Figured it out. @flovilmart, You were on the right track... thank you for your suggestions. In the case of 'updating' an object, I was including a dictionary entry for the Receipt. This was successfully retrieving the Receipt that I wanted to update. However, the issue was that once I pulled in the receipt object and was iterating through my dictionary of properties... I ran into the Receipt object information again. Thus I was trying to add a property of Receipt pointer to my Receipt with the pointer being itself! Ugh. The very last else clause needed a condition on it to NOT include the pointer to Receipt (itself)
|
Issue Description
I have a simple Cloud Code command to create or update an object. If there is NO objectId passed in, the routine creates a new object and returns the objectId. If the objectId exists in the parameter list, it fetches the object and updates the parameters accordingly.
The routine works for new objects fine.
The object.save() is failing when I try to update an object, despite the object.fetch() sub-routine working.
error: code=101, message=Object not found.
Verbose server logs indicate a very strange PUT command...
verbose: PUT /parse/classes/Receipt/[object%20Object]**
Object ACL is public r+w
Cloud Code
Steps to reproduce
Expected Results
Object should be updated accordingly
Actual Outcome
error: code=101, message=Object not found.
Environment Setup
Logs/Trace
** Storing NEW object returns **
** Attempt to Update object returns **
The text was updated successfully, but these errors were encountered: