Skip to content

fix: Answer unhandled REST requests with a not found error - #49

Merged
joamag merged 1 commit into
masterfrom
bug/rest-not-handled-404
Oct 1, 2026
Merged

joamag merged 1 commit into
masterfrom
bug/rest-not-handled-404

Conversation

@joamag

@joamag joamag commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Fixes OMNI-LDJ-14.

Cause

A request whose path is matched by no route of the REST service plugins raises RESTRequestNotHandled (rest/src/rest/system.py), which, unlike its siblings MVCRequestNotHandled and the RequestNotHandled of the colony HTTP handler, carries no status_code. The WSGI handler falls back to 500 for exceptions without one, so the client receives an internal error, the exception is logged with error verbosity and it reaches Sentry through the logging handler, as the client error filter of #45 only recognises the exceptions that carry a 4XX status code.

The Sentry event has no request context (URL, method) because request.begin is only notified once a route matches, which never happens for these requests.

Changes

  • RESTRequestNotHandled takes a status_code defaulting to 404, mirroring MVCRequestNotHandled, so the WSGI handler answers with a not found error, logs it with debug verbosity and Sentry ignores it as a client error
  • CHANGELOG entry under Fixed

Verification

  • test_handle_request_not_handled routes a request with no REST service plugin and with one whose routes do not match, asserting the error and its 404 status code, then registers a matching route to confirm that the lack of it was the cause
  • test_rest_request_not_handled asserts the default status code and test_rest_request_not_handled_custom_status a provided one
  • The 3 tests fail against the previous code ('RESTRequestNotHandled' object has no attribute 'status_code') and pass with the change
  • 100% coverage of the changed statements (4 of 4), measured with coverage.py
  • Complete suite passing locally (23 bundles, 1282 tests) and black --check clean

- The REST not handled error now carries a 404 status, as its MVC sibling does
- Unmatched requests no longer answer with a 500 nor get reported to Sentry
- Tests cover the status code and the routing of unmatched requests
Fixes OMNI-LDJ-14
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 7ebe33dd-e80a-430c-8295-9ec7d4d54c94

📥 Commits

Reviewing files that changed from the base of the PR and between 40a4b9b and a90f577.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • rest/src/rest/exceptions.py
  • rest/src/rest/test.py
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@joamag
joamag marked this pull request as ready for review October 1, 2026 07:38
Copilot AI balanced review requested due to automatic review settings October 1, 2026 07:38
@joamag joamag self-assigned this Oct 1, 2026
@joamag joamag added the enhancement New feature or request label Oct 1, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-01T07:40:28.229608Z a90f577 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@joamag

joamag commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused, backward-compatible change matches established MVC behavior and has appropriate regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Adds HTTP 404 handling for unmatched REST routes, preventing false server errors and Sentry reports.

Changes:

  • Adds a default/custom status code to RESTRequestNotHandled.
  • Tests unmatched routing and exception status codes.
  • Documents the fix.
File Description
rest/​src/​rest/​exceptions.py Adds the default 404 status code.
rest/​src/​rest/​test.py Covers unmatched routes and status codes.
CHANGELOG.md Records the corrected behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: a90f577333

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@joamag joamag left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM

@joamag
joamag merged commit 34217c1 into master Oct 1, 2026
39 of 40 checks passed
@joamag
joamag deleted the bug/rest-not-handled-404 branch October 1, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants