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

Incorrect HTTP response codes. #80

Closed
andacata opened this issue Feb 8, 2024 · 1 comment · Fixed by #81
Closed

Incorrect HTTP response codes. #80

andacata opened this issue Feb 8, 2024 · 1 comment · Fixed by #81
Labels
bug Something isn't working module: transport

Comments

@andacata
Copy link
Contributor

andacata commented Feb 8, 2024

The HTTP response code is automated based on the OCPI response code:

status = when (ocpiResponseBody.status_code) {
OcpiStatus.SUCCESS.code -> if (ocpiResponseBody.data != null) HttpStatus.OK else HttpStatus.NOT_FOUND
OcpiStatus.CLIENT_INVALID_PARAMETERS.code -> HttpStatus.BAD_REQUEST
else -> HttpStatus.INTERNAL_SERVER_ERROR
},

Currently, the code returned is HTTP 500 on any response that is not SUCCESS or CLIENT_INVALID_PARAMETERS. So returning any of the other OCPI errors will result in an HTTP 500 error.

The documentation states that

If a request is syntactically valid JSON and addresses an existing resource, a HTTP error MUST NOT be returned. Those requests are supposed to have reached the OCPI layer.

so all these responses should be and HTTP 200.

I've asked for my thoughts on this in the OCPI Slack: https://ocpi.slack.com/archives/C0S64NZJQ/p1707299786355599
and confirmed by one of the authors of the OCPI documentation 😅

Maybe related with #65

@lilgallon lilgallon added bug Something isn't working module: transport labels Feb 8, 2024
@lilgallon
Copy link
Member

Indeed, this code has to be updated to return 200 instead of 500. Concerning #65, I think that it should be fixed separately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module: transport
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants