-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
PUT in REST API does not upsert object with custom ID #7139
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
Comments
Thanks for suggesting. If I understood your description correctly, there are two separate suggestions: a) Add setting custom object ID to Parse JS SDK Regarding the Parse JS SDK, there is already an open issue for setting a custom object ID, see parse-community/Parse-SDK-JS#1097. When adding the custom ID option to the Parse JS SDK, then the Regarding the REST API, the equivalent of a database
If you save an object with a custom ID using the REST API, and a Note: I have renamed the title of this issue to limit its scope on the REST PUT operation, which is the "upsert" behavior for the REST API you are suggesting (b). For the Related: |
Hi @mtrezza, Thanks for the response. I have confirmed that PUT request for non existent object is not working, it gives error. |
Thanks for confirming, can you please create a Pull Request and write a test case for this? |
Can you please give me suggestion about where I can write test case? Do I have to pull parse-server repo and put test case there? or separate code would be sufficient? |
Yes, you would
You can find more details in the Contribution Guide. Don't get scared, the guide needs some rework and we're working on it. If you need any guidance please feel free to ask. |
@ArkeshGKalathiya Do you need any help for creating a test case? |
@mtrezza No, I was just busy with other stuff. I will soon add test case and submit PR. |
@ArkeshGKalathiya I added customID to the JS SDK. Feel free to provide feedback |
This issue with PUT requests still persists. I believe this issue should be re-opened. |
I'm not sure why this was closed, seemingly by mistake, because the ref PR is about custom IDs, @dplewis? Maybe they are two different issues? I think we can reopen if we have a failing test case. |
I don't think there is a test case that covers this. |
@mstniy Would you want to add a test case? |
Sure thing. My understanding is that What should a pure (non-upsert) update look like? Should the PR fix the issue with |
A That is the HTTP standard. That being said, if Parse is currently violating that standard, we'd have to look into what a correction implies in terms of scope of changes internally and breaking changes for existing deployments. |
It seems Parse is indeed violating the standard. From the docs about PUT requests:
So the current |
That sounds like a violation of http/1.1. A RFC 5789 says:
and
What happens when making a |
Quoting the specification you have mentioned:
Currently, Parse returns an OBJECT_NOT_FOUND |
You get that response for PUT or PATCH? Also, we should be careful with citing specs, because part of them may be outdated. Before PATCH has been introduced, servers used PUT to update objects, deliberately violating the spec. That led to the introduction of PATCH. The first spec I posted is from 1999, the second from 2010 which modified parts of RFC 2616. |
For PUT I don't think Parse uses PATCH? |
So if I understand correctly, there are 2 issues:
|
I agree |
I suppose fixing (a) would be a breaking change, but possibly not have wide implications for Parse SDKs. It would only be a breaking change for mechanisms that are depending on PUT failing for non-existent objects. Making a PUT for a non-existent object is probably unintended in most cases anyway. Fixing (b) would likely affect all Parse SDKs, and may not be worth the effort for now. |
Introducing upserts as a query string option sounds like a good compromise. |
Not sure about that, shouldn't we rather go into the direction of correcting the behavior instead of leaving the incorrect behavior in place and adding an option? Adding an option seems like adding a 5th wheel to a car because it has a flat tyre. |
I would be happy to do that, as our use case wouldn't be negatively affected. |
A breaking change that is actually a correction (of the http spec violation) is generally acceptable. I am just not sure what that change implies.
|
Here's my take:
I am not sure as to whether any mechanism would be affected. |
It seems what you are suggesting is to become fully spec compliant. If that was easily achievable without major implications I would agree. If there are major implications, we may need to be a bit more pragmatic. Parse Server works after all, even if it is not fully spec compliant. We could look at these changes:
Which of these changes we make depends on the implications for the product and developers. Thinking about timeline, we already have a lot of other breaking changes accrued for Parse Server 5, so I wouldn't expect fundamental breaking changes like (c) above to go into effect before Parse Server 7 (~Jan 2023). |
Reopened because issue still seems to exist. |
@mstniy suggested steps seems reasonable to me as they would hopefully yield the least of amount of errors added to the server (and salvage all of the current The changes on the client SDKs will most likely follow the same process and should be easier to do (thinking from the Swift SDK and probably some of the others, this would be straight forward). To the point of:
Will something like Maybe when these changes occur, we can take advantage of the Lines 3 to 22 in 9ea355b
When a client's version is compatible, use the correct version of Of course, if someone uses a "patched" client SDK with an non "patched" server they will have unexpected behavior. |
No, I haven't created a PR yet |
Thanks, I think we agree so far that this requires a significant change affecting all SDKs, if we want to solve this sustainably. Deprecating a feature across all SDKs is a novelty in the context of our newly introduced Deprecation Policy. The question is how to do it in a way that is:
Luckily we have some tools:
Do we already agree on which approach to take? I think we'd need to compare implications. |
I think what I meant here is |
I would imagine the developers who will run into the most issues are the ones who don’t use the Client SDKs and instead use REST or Graph directly, but we can assume those who to send the |
Following @mtrezza’s approach seems right to deprecate in a step-by-step way. My question here, is this process needed because of the tools already available? Meaning following the process @mstniy mentioned and I commented on here may fix this now without causing issues (I’m saying this without seeing the CI updates of course) because it will automatically support the current way and the new way. Note that when the SDKs get the fix (avoiding “patch” because of the context of the convo) many of them will also need to add the |
Ah right, we need to give an option to update vs. upsert. |
I've edited this comment several times now, I think I'll have to sleep over this 🙂 |
Some things to think about when it comes to server responses for ParseObjects. Currently a The proposed changes seem to leave |
TL;DRFor now I suggest to only add an Let's try to break this down... There are two separate issues:
These two issues can be looked at individually, because:
This means that (b) will pose the challenge to developers, because if they want to upgrade to a new SDK version, they will have to upgrade to new Parse Server as well. Upgrading Parse Server is currently a major obstacle for many deployments, because Parse Server 5.0 will bring many changes, some of them breaking. Many deployments seem to run on old versions of Parse Server and there is a certain "upgrade fatigue" because in the past we had no deprecation policy, sudden breaking changes, infrequent and non-matured releases, no LTS, etc. This situation is expected to improve dramatically from Parse Server 5.0 onwards and over the course of 2022/23. This means we are not in a good place at the moment to fix (b) by introducing a breaking change that will be a burden for many developers. It would also be an unnecessarily high burden, because (b) is merely a formality. So I suggest to fix (b) when we can expect a majority of developers having jumped onto the release train because they know that keeping their deployments up-to-date is almost effortless. I expect that to be sometime in 2023/24. If we solely focus on (a), an approach could be:
To prepare for the breaking change in 2023/24:
Sometime in 2023/24 (Parse Server 6/7):
@cbaker6 This is rather long, but I would appreciate if you could examine the details and let me know your opinion. |
In attempt to have the Swift SDK as close to spec compliant as possible while still making it work with the current Parse Server, I made changes in parse-community/Parse-Swift#299. Just further confirming that when I remove the guard on objectId when attempting to
The same results occur no matter the server setting, I've created a branch of ParseSwift for testing upsert in Swift Playgrounds whenever development on the server-side for upsert and |
Any update? How can I help on this? |
@ArkeshGKalathiya You could read through this thread and suggest a PR. |
New Feature / Enhancement Checklist
Current Limitation
When integrating third party apis with server, most of them already provide the unique ids for the returned data. So right now if I want to save object with custom id it requires restful api call from node environment, and to make restful api call ( batch request ), we need to check with the server if object with custom id exist or not. If object exist then batch array requires PUT otherwise it requires POST. So it is kind of little overhead and extra management of the code. And also in fast updating environment it can cause errors ( where multiple node in same cluster checks with the backend if certain object id exist, it can cause race conditions ). so It would be nice to have support for saving objects in node environment without rest apis, and maybe upsert option when saving parse object.
Feature / Enhancement Description
So It would be great to have feature where parse server sdk supports saving object based on custom object ids ( it doesn't support at the moment in cloud code and server sdk, it requires rest api cal in node environment to save such objects with custom object id ) and one flag with something like Parse.Object.save({},{upsert:true}), which updates existing documents if object id is already there in database.
Alternatives / Workarounds
Making redundant requests to check if object exist in server
The text was updated successfully, but these errors were encountered: