Skip to content

Rest: Return validation errors from the database handlers#241

Merged
masnax merged 3 commits into
canonical:v3from
roosterfish:return_db_errors
Aug 23, 2024
Merged

Rest: Return validation errors from the database handlers#241
masnax merged 3 commits into
canonical:v3from
roosterfish:return_db_errors

Conversation

@roosterfish
Copy link
Copy Markdown
Contributor

Fixes #240

This PR ensures that any request validation for the database handlers happens before hijacking the connection so that errors can be returned to the caller.

Make sure to run the database request handler before actually hijacking the connection.
This ensures errors occurred during request validation can still be forwarded to the caller.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
If the request path is database related and the response is not of type EmptySyncResponse
return the error to the caller as the connection wasn't yet hijacked.

Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
Signed-off-by: Julian Pelizäus <julian.pelizaeus@canonical.com>
@roosterfish roosterfish requested a review from masnax August 22, 2024 12:13
Copy link
Copy Markdown
Contributor

@masnax masnax left a comment

Choose a reason for hiding this comment

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

LGTM!

@masnax masnax merged commit a4c5273 into canonical:v3 Aug 23, 2024
@roosterfish roosterfish deleted the return_db_errors branch August 23, 2024 15:00
@masnax
Copy link
Copy Markdown
Contributor

masnax commented Aug 23, 2024

Should this get backported to v2?

@roosterfish
Copy link
Copy Markdown
Contributor Author

Should this get backported to v2?

Yes I'll create a PR.

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.

"Forbidden" database errors are silently ignored

2 participants