Skip to content
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

/api/entityid doesn't properly process JSON strings #67

Open
veselov opened this issue Feb 3, 2021 · 2 comments
Open

/api/entityid doesn't properly process JSON strings #67

veselov opened this issue Feb 3, 2021 · 2 comments

Comments

@veselov
Copy link

veselov commented Feb 3, 2021

Input data to /api/entityid (and similar endpoints that accept a single string), don't quite make sense me. The endpoint accepts JSON, so I am expected to send a valid JSON data.

However, the schema for that data is just string. So the only valid JSON data I can send is a JSON string (e.g. "abc"). However, if I do so, the entire value I sent is treated as the entity ID (including the quotation marks). I'm, therefore forced to send the string without the quotation marks, which makes my input not valid JSON data, and disagrees with the content type of the request data.

Using text/plain content type causes the server to reject the request.

P.S. I'm not entirely sure this is Mujina's issue, looking at the code, it's all Spring annotations. However, I don't know much about Spring, so may be there is a way to configure this (i.e. it's not a Spring bug).

@oharsta
Copy link
Member

oharsta commented May 2, 2021

A single string is valid JSON. If I run Mujina IdP locally and use the API:

curl -v -H "Accept: application/json"  -H "Content-type: application/json"  -X PUT -d "myEntityId"  http://localhost:8080/api/entityid

Then the entityId is changed and the log outputs the following:

INFO  mujina.api.IdpController - Request to set entityID myEntityId

@veselov
Copy link
Author

veselov commented May 2, 2021

A valid json string requires to be wrapped in double quotes ("), according to https://www.json.org/. What you've sent in your CURL command above is entityId, as the double quote characters you've specified in the command are interpreted by the shell. If you used:

curl -v -H "Accept: application/json"  -H "Content-type: application/json"  -X PUT -d '"myEntityId"'  http://localhost:8080/api/entityid

you'd see the cluster name set to "myEntityId" instead, because the value is not interpreted as a JSON string, but as a literal string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants