-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Use context header to accept context instead of modifying body #7438
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
What is the bigger picture here? Do we want to change all SDKs to transmit the context in the header? |
What about
Not sure, the header way is better IMO, but if the SDK's are injecting |
The context is actually not an "object" context but a Cloud Code Trigger context. What is passed in the context is made available in the triggers. I can't think of any extension beyond triggers, but if
I would agree. I am not sure why I implement this as part of the body, but a comment from back then makes me think it was for a reason:
I'll see if I can find out the reason. Also see this comment. |
It seems like a small oversight to me since |
Yes, About the implementation, let's see...
|
If there's no size limitation then what's the problem? Also, if there are practical size limitations on specific deployments then the simple solution is to document it saying, "be sure to respect your actual header limits". That should be left to the developer to control. Either way, the PR doesn't jeopardize the previous way (as nothing was deleted) and only provides a way for SDKs who don't want to hack the body as I mentioned before.
This is hacky and not good code IMO. Adding to private vars and removing looks ugly and seems unmanageable. Not to mention, doing things like this prevent the developer from using such keys in their objects. |
"Internal" keys with leading underscore are a concept throughout parse server, so that couldn't happen. But you are right, it seems hacky. I think the issue is that Parse Server uses the whole HTTP body JSON object as a Parse Object definition, not allowing any "meta" info to be passed. That looks like a design flaw. It seems to make sense to transmit it as a header. I think however we should use one way of specifying the context and gradually change the other SDKs to use the header too. |
Using one way makes it easier to manage, but of course would require multiple PR's and knowledge across all of the SDKs to implement the change. Currently multiple private vars have header counterparts: Header: parse-server/src/middlewares.js Lines 25 to 39 in 9ea355b
Private/Underscore keys: parse-server/src/middlewares.js Lines 80 to 115 in 9ea355b
|
That is interesting, so if any of these are specified in the body and in the header, the body overrides the header? |
I believe so, from my interpretation of the code. This also showed when I was debugging the fix. |
Then I take back my previous comment, because overriding header via body can be considered expected behavior / a feature. It seems your PR was the correct approach after all. |
It seems the only SDKs that have the ability to use The JS SDK uses the |
I also looked into php, because acinader mentioned he would add this to the sdk, but it doesn't seem to be there.
I think we concluded that - as with other fields - both should be possible, with body overriding the header, correct? |
Yes, both are still possible and both are still tested |
🎉 This change has been released in version 5.0.0-beta.1 |
🎉 This change has been released in version 5.0.0 |
New Feature / Enhancement Checklist
Current Limitation
Currently,
context
can only be used by injecting a_context
key/value into the body when using REST. This is problematic for SDK's that encode objects without modifying the body like the Swift SDK. This was originally discussed on community.parseplatform.org.Feature / Enhancement Description
Currently,
context
is setup to be accepted in the header, but doesn't have an actual header:parse-server/src/middlewares.js
Lines 25 to 39 in 9ea355b
Adding a new header
X-Parse-Cloud-Context
will address the issue.Example Use Case
Using REST:
parse-server/spec/CloudCode.spec.js
Lines 2537 to 2548 in 0c23bfd
Alternatives / Workarounds
No workarounds for using context in the header. Will have to modify the body with
_context
like the other SDKs.3rd Party References
The text was updated successfully, but these errors were encountered: