-
Notifications
You must be signed in to change notification settings - Fork 26
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
Ruby SDK reject_params throws JSON parsing error #760
Comments
Hello again! Happy to carry on the discussion here or on intercom. Up to you! Mind making your repo public so i can check it out? 🙏 |
Hi @domharrington thank you again for your time. I thought this might be easier to track. I've updated my test repo to make it public. |
Hey! Sorry for the delay... still trying to get your demo repo up and running. In the mean time, i've pushed my repo up as well: https://github.com/domharrington/ruby-reject-params-metrics-demo You should be able to add your API key here to get it running: https://github.com/domharrington/ruby-reject-params-metrics-demo/blob/b4420ee12b48cfabb681a4f27ab723c765489c1a/config/environments/development.rb#L5 I am continuing to try and get yours running, but I didnt have rbenv installed and my system ruby is 3.2.1. Now i'm getting a compilation error when installing the I will update you with any progress, if you wanna check out my demo as well that may be helpful. |
Hey! I managed to get it running after installing and running postgres, and it seems to be working as intended: $ curl http://localhost:3000/api/participants -i
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
Content-Type: application/json; charset=utf-8
ETag: W/"4022a1a46e01af68a53eede300bcffdf"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 09e3b75a-0eef-4a98-ad59-2a11f7913e28
X-Runtime: 0.001879
Transfer-Encoding: chunked
{"data":[{"attributes":{"id":"testeid","email":"[email protected]","firstName":"first","lastName":"last"}}]}% Then it came through into Metrics like this: I have made no changes to your repo, apart from replacing Is there anything else that may be different about your system or setup? I'm using the Ruby version that's defined in your Gemfile too. Really appreciate your patience on this and you helping me to debug this! I hope we can get to the bottom of it. |
@EOengineer Hey! Did you manage to take a look at this yet? Very happy to jump on a call to help debug if you're willing. Looking forward to hearing from you! |
@domharrington Thank you for your patience. My apologies, I must have made a mistake troubleshooting - the |
Thank you! Please do let me know if there's anything we can do here to assist, I'm more than happy to make changes if something we're doing is incompatible and there's something we can reasonably tackle. Let me know! |
@domharrington I wanted to follow up with some findings after doing some debugging against my application. What I discovered was that, at least in my case, the @request.body in the This issue was only present when passing the
I'm wondering you have thoughts or concerns around guarding against json requests with empty bodies, or why that condition might cause problems. I assume this may be by design since the code seems to rely on lower level errors bubbling up and being caught top level here but I thought I would at least alert you to the possibility that an issue exists that could potentially be circumvented with a seemingly minimal code change. |
Would you mind sending me a curl command (with $ curl -X POST https://httpbin.org/post -i
HTTP/2 200
date: Wed, 15 Mar 2023 15:42:14 GMT
content-type: application/json
content-length: 318
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/7.86.0",
"X-Amzn-Trace-Id": "Root=1-6411e756-5b861309443a7cdb57baab4c"
},
"json": null,
"origin": "82.5.182.239",
"url": "https://httpbin.org/post"
} Or something else? When I can repro, I can add a test case and hopefully get this fixed up. |
@domharrington following up...these requests are against the test app linked earlier in this thread. The JSON parsing error is occurring when provided a request body as an empty string. But if I change the body to an empty string like so: You will see the parsing error thrown: An interesting note - the parsing error only occurs when the
|
Thanks for following up, and thanks for the curl command! I think this may be us making an (incorrect, but almost always okay) assumption that GET requests dont have bodies. I will dig into this and get back to you! Should be pretty easy to write a test case for this! |
@domharrington Did you have any luck reproducing this error? |
I have not tried just yet, but I think it's to do with the GET method sending a body. Can you configure postman to omit the body completely, not just send an empty body? |
I've configured postman to not send string bodies. At least within our application, I don't believe the string is originating from the requests. I'm noticing our body shows as this
I've now forked the SDK and am investigating whether this is something I can fix before we move on to explore other options. |
Hey @EOengineer, really appreciate the patience on this. I'm currently up against it on another project, but I should be able to dedicate some time to reproducing and fixing this in the next 3/4 weeks. If you can reproduce and send a PR through, that would be fantastic! I should be able to review anything you put together. Let me know if I can help! |
Description
When I use the reject_params configuration option I get the following error:
To Reproduce
Clone my test/reproduction app here
install
Fire off a JSON API GET request to
localhost:3000/api/participants
- error should be visible in consoleRemove
reject_params
config option, the code works as expected.Additional details
Config looks like
System details:
The text was updated successfully, but these errors were encountered: