-
-
Notifications
You must be signed in to change notification settings - Fork 949
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
fix: Internal Server Error on Empty PUT /identities/id body #2417
Conversation
Just a quick check here. I was trying to reproduce the issue and got "ERR_DNS_FAIL" when attempting to connect to http://kratos:4434/identities . Also, if instead I do curl to http://127.0.0.1:4434/identities/ then that attempt results into "Temporary Redirect". So, before proceeding wanted to confirm if there are any proxy settings in the source code that needs to be taken care. Thanks, |
Also, I started with the quickstart and I am able to follow along with the demo. Only issue is when trying to reach to http://kratos:4434/identities. Please do not review the fix now, I created the PR with minimal changes to clarify some doubts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to reproduce the issue and got "ERR_DNS_FAIL" when attempting to connect to http://kratos:4434/identities . Also, if instead I do curl to http://127.0.0.1:4434/identities/ then that attempt results into "Temporary Redirect".
This depends a bit on your test setup. If you run everything using docker-compose on localhost, you want to use http://127.0.0.1:4434
. The OP used this setup:
I execed into the Postgres image, installed curl, ad called
curl -s http://kratos:4434/identities/c8d98079-c6c0-49e1-a034-92fa2269724b
With docker networking that will be resolved properly, but you can also just use the loopback interface from outside of docker.
Now the redirect is happening because we recently added the path prefix /admin
for admin endpoints. Therefore, you can test your fix using curl -v -X PUT http://127.0.0.1:4434/admin/identities/c8d98079-c6c0-49e1-a034-92fa2269724b -H "Accept: application/json"
.
In the end, it would be great to also have a go unit test for this case. There are already other tests where you can just add one more subtest, without the need to setup everything.
Hi @VeenaInd Thank you for taking the time to work on this :) You don't need to compile and run Kratos with the whole configuration setup manually to test this. I would suggest adding a test case to the You can find an example of such a test here kratos/identity/handler_test.go Lines 428 to 459 in 562e340
Also please sign the CLA agreement so that the CI can run the tests. |
Thanks @zepatrik and @Benehiko for this guidance. curl -v -X PUT http://127.0.0.1:4434/admin/identities/c8d98079-c6c0-49e1-a034-92fa2269724b -H "Accept: application/json". is good one to replicate the scenario. I am able to get the exact error with this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, we would just need some handler tests to verify the fix
Also please rebase with |
Signed-off-by: Veena Saini <veena.code.assignment@gmail.com>
Signed-off-by: Veena Saini <veena.code.assignment@gmail.com>
7d1e584
to
807dc2e
Compare
Signed-off-by: Veena Saini <veena.code.assignment@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @VeenaInd
Thank you for working on this, it's looking great so far :)
There are just a few minor changes that need to be made. I also see the CI doesn't run all the tests due to linting problems, you can resolve this by doing make format
in the root of the Kratos project. It uses goimports
and npm so you would need to install that for this to work.
Lines 134 to 138 in a42a0f7
# Formats the code | |
.PHONY: format | |
format: .bin/goimports node_modules | |
goimports -w -local github.com/ory . | |
npm run format |
Signed-off-by: Veena Saini <veena.code.assignment@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this looks very good now from my side 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! LGTM :)
I think github packages are down at the moment which the docker image scanner relies on afaik. The other failures might be flakes https://github.com/ory/kratos/runs/6154892204?check_suite_focus=true#step:16:1398 We can also just wait a bit until Github is fully operational and re-run everything later. |
ok, thank you. |
Hello @VeenaInd |
Thank you @vinckr. I am glad, I got this opportunity to work on ory project :) . |
Signed-off-by: Veena Saini veena.code.assignment@gmail.com
Description of the changes
This PR fixes the issue #2307.
Currently if a user sends HTTP PUT request with empty json data or incorrect json path (means the file does not exist), then that results into "internal server error". This error message is a generic and creates confusion.
Empty json (or we can say http request without body) triggers io.EOF error. This PR provides the user a better error message when io.EOF error is encountered.
Affected Module: Identity Update
There can be other scenarios of malformed user requests that may trigger "internal server error" during identity update, but those are not handled in this PR.
Related issue(s)
Checklist
introduces a new feature.
contributing code guidelines.
vulnerability. If this pull request addresses a security. vulnerability, I
confirm that I got green light (please contact
security@ory.sh) from the maintainers to push
the changes.
works.
Further Comments