-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Parse settings as JSON 5 in services #11734
Parse settings as JSON 5 in services #11734
Conversation
Thanks for making a pull request to jupyterlab! |
Kicking the CI |
I think it would be better if the server did not send nonstandard JSON (for example, it could send the setting just as raw text to be interpreted as JSON5 on the frontend). If we send nonstandard JSON in response to a settings request, it breaks the expectation of the rest api that the response is valid JSON. |
I'm not sure to get it. You would like to do something like this on the server:
And similarly on the frontend to ensure user settings sent are valid json? So that we will allow json5 syntax but reject specific things like |
No. I would send the json5 source as a raw unparsed string, and then parse that string on the frontend as json5. That way what comes over the wire is actually valid JSON. |
Bumping from |
@jasongrout I have a trouble with this one. If I got it correctly, the So how do we achieve changing |
Should we test for the content type header? Should we use |
I was proposing sending settings as a raw string as a breaking change in jlab server. |
As there is always a sequenceDiagram
frontend->>server: GET settings
activate server
Note right of server: Get format from `Content-Type`
server->>frontend: Send settings
Note left of frontend: Store save format from `Content-Type`
The server would keep its current behavior if the content-type is not What do you think? |
I think using the content type would technically work, but it would be the first rest endpoint that didn't return JSON, which I think is a bigger architecture decision. I think I'm -0.5 on sending something other than JSON, just because there is a very standard convention to send JSON for rest endpoints. If it keeps sending JSON, then it keeps being broken. If we stop sending JSON, then there will be lots of confusion about it, I think. In my mind, I was imagining a breaking change in jlab server where we send different JSON (the raw string), and us depending on it in jlab 4.0, and making a clean cutover then. Iirc, we already have this pattern of sending a raw string, so we'd just be applying that existing pattern here. |
Sorry we misunderstood each other. I had in mind to send a raw string as you propose but using the content type to flag that the attribute is a raw string that need json5 parsing. But this is not a great idea (hence our misunderstanding) as by looking at the content type people will think the body they got does not need an additional parsing. So closing this as the approach will be different. |
Ah, I see what you were saying. Yes, I agree that we'd be misapplying the json5 content type in this situation (well, technically not because IIRC json is a subset of json5, but it would still be confusing). |
References
Fixes jupyterlab/jupyterlab_server#217
Code changes
Parse response from in settings service as JSON 5 not standard JSON.
User-facing changes
Settings can be JSON 5 - in particular
Infinity
can now be used.Backwards-incompatible changes
N/A