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

fix: change failed query with missing db to 404 #25693

Merged
merged 2 commits into from
Dec 20, 2024
Merged

Conversation

mgattozzi
Copy link
Contributor

This changes the status code of a failed query that uses a db that does not exist. We now instead return a 404 rather than the default 500 code

Closes #25653

This changes the status code of a failed query that uses a db that does
not exist. We now instead return a 404 rather than the default 500 code
let serialized = serde_json::to_string(&err).unwrap();
let body = Body::from(serialized);
Response::builder()
.status(StatusCode::NOT_FOUND)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be easy enough to get a test added to assert the status?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah should be easy enough! Surprised we don't already have one now that I think about it

Copy link
Contributor

@praveen-influx praveen-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - if it's not too much hassle a test to assert the status will be good.

Not sure if we need to align the error messages returned to user. In some cases it's just string and in some cases it's a JSON string - probably in a separate ticket.

@mgattozzi
Copy link
Contributor Author

@praveen-influx added the test so I'll merge it when it all passes

@mgattozzi mgattozzi merged commit 2a132f1 into main Dec 20, 2024
13 checks passed
@mgattozzi mgattozzi deleted the mgattozzi/not-found branch December 20, 2024 16:53
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

Successfully merging this pull request may close these issues.

Cleanup: Update "database not found" to a 404 error, rather than a 500
2 participants