Skip to content

fix(rest): return 400 only for an invalid cursor - #254

Merged
PromiseFru merged 1 commit into
smswithoutborders:stagingfrom
SAY-5:fix/rest-400-invalid-cursor-only
Nov 20, 2026
Merged

PromiseFru merged 1 commit into
smswithoutborders:stagingfrom
SAY-5:fix/rest-400-invalid-cursor-only

Conversation

@SAY-5

@SAY-5 SAY-5 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Closes #209

The REST app sent every ValueError and NotImplementedError to _bad_request_handler, so a server fault such as the wrong SQLCipher key came back as a 400 with the internal message. The handler is now registered for InvalidCursorError only, as the issue suggests, and everything else reaches the generic 500 handler. I checked the other ValueError raisers a route can reach (server_identity_key, publication_stats group_by, db/types) and their inputs are already validated by FastAPI, so they are server faults too.

The new test in tests/api/rest/test_server_keys.py makes the list route raise the wrong-key ValueError and fails with a 400 without the change. ruff, pyright, import-linter and the pytest suite pass locally on Python 3.12 (the only failures are the tests/scripts shell tests, which fail the same way on staging on macOS, and the sqlcipher3 engine test, which has no macOS wheel). Nothing to do on deploy.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>

@PromiseFru PromiseFru left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, this looks good!

@PromiseFru
PromiseFru merged commit e74ea60 into smswithoutborders:staging Nov 20, 2026
12 checks passed
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.

2 participants