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

Make http.send accept any json variant as application/json #6684

Open
mrvanes opened this issue Apr 9, 2024 · 7 comments
Open

Make http.send accept any json variant as application/json #6684

mrvanes opened this issue Apr 9, 2024 · 7 comments

Comments

@mrvanes
Copy link

mrvanes commented Apr 9, 2024

What is the underlying problem you're trying to solve?

Our SCIM server returns application/scim+json as a Content-Type header. We need to enable force_json_decode to get the raw_body parsed into body.

Describe the ideal solution

It would be nice if opa would understand that application/variant+json is just a variant of application/json for any variant of json so it would not be necessary to add force_json_decode to the request body.

Describe a "Good Enough" solution

users_request := {
    "url": "https://scimserver/Users",
    "method": "GET",
    "headers": {
        "x-api-key": "secret",
        "accept": "application/scim+json"
    }
}

... would return a valid decoded body in the result.

@anderseknert
Copy link
Member

Sounds like a reasonable improvement to me. If you'd like to submit a PR, that'd be neat 🙂

@srenatus
Copy link
Contributor

srenatus commented Apr 9, 2024

"For more information, please re-read." -- I've removed my comment re force_json_decode, you're already aware. 😅

@srenatus
Copy link
Contributor

srenatus commented Apr 9, 2024

💭 Right now, application/json is json-decoded, and application/yaml + application/x-yaml are yaml-decoded. So if we go with

users_request := {
    "url": "https://scimserver/Users",
    "method": "GET",
    "headers": {
        "x-api-key": "secret",
        "accept": "application/scim+json"
    }
}

would this mean it should do JSON? How would I declare that a certain extra header value means that it should be treated as YAML?

@mrvanes
Copy link
Author

mrvanes commented Apr 9, 2024

No, my suggestion was not to use the "accept" header, that's just to show a correct SCIM request body. My suggestion is to be lenient about the returned application/<anything+>json Content-Type.

@srenatus
Copy link
Contributor

srenatus commented Apr 9, 2024

Ah! Thanks for clarifying. Yeah, that makes this a bit simpler.

@ashutosh-narkar
Copy link
Member

This method handles the response processing which would need to be updated I think. Feel free to submit a PR if you'd like. Thanks.

Copy link

stale bot commented May 9, 2024

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.

@stale stale bot added the inactive label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants