Skip to content

fix(announcements): degrade 404 on /announcements/latest to null instead of erroring#4417

Open
nazarli-shabnam wants to merge 2 commits into
tinyhumansai:mainfrom
nazarli-shabnam:fix/4401-announcements-404-sentry
Open

fix(announcements): degrade 404 on /announcements/latest to null instead of erroring#4417
nazarli-shabnam wants to merge 2 commits into
tinyhumansai:mainfrom
nazarli-shabnam:fix/4401-announcements-404-sentry

Conversation

@nazarli-shabnam

Copy link
Copy Markdown
Contributor

Summary

GET /announcements/latest returning 404 in prod (a backend deploy gap tracked separately in tinyhumansai/backend#1064) was being funneled into report_error at two layers:

  • authed_json's generic non-2xx handling (Sentry TAURI-RUST-HW0)
  • the RPC dispatch re-wrap in core/jsonrpc.rs (Sentry TAURI-RUST-KHX)

One 404 → two Sentry events, ~452 events / 19 users, for a purely cosmetic, best-effort announcement fetch that announcementService.ts already documents as "a missing announcement is never worth surfacing an error for."

Fix

Mirrors the existing BackendApiError::MessageNotFound precedent in src/api/rest.rs:

  • Added BackendApiError::AnnouncementNotFound, a typed error for 404 on GET /announcements/latest specifically (exact-path + method match, scoped — not a blanket demotion of all 404s).
  • authed_json now returns this typed error for that one route instead of falling through to the generic non-2xx report_error path.
  • announcements::ops::get_latest_announcement intercepts it and degrades to Value::Null, matching the function's own documented contract ("the backend returns the announcement object or null when nothing qualifies; both pass through verbatim").
  • Any other failure (5xx, malformed response, session expiry, a 404 on a different path) still propagates via flatten_authed_error and still reaches Sentry — this fix does not suppress genuine failures.

Tests

  • authed_json_surfaces_announcement_not_found_on_404 — 404 on /announcements/latest surfaces the typed error.
  • authed_json_only_classifies_get_announcements_latest_as_not_found — a 404 on a different/adjacent path is not misclassified (defense-in-depth).
  • flatten_authed_error_does_not_swallow_announcement_not_found — the typed error still round-trips correctly if it ever reaches flatten_authed_error directly.
  • announcement_not_found_error_is_detected / other_backend_errors_are_not_announcement_not_found — network-free unit tests for the downcast logic in ops.rs.

Related

…ead of erroring

GET /announcements/latest returning 404 in prod (backend deploy gap,
tracked separately in tinyhumansai/backend#1064) was funneled into
report_error at two layers - authed_json's generic non-2xx handling
(TAURI-RUST-HW0) and the RPC dispatch re-wrap (TAURI-RUST-KHX) - for
a purely cosmetic, best-effort fetch that should never be worth an
error, let alone two.

Mirror the existing BackendApiError::MessageNotFound precedent: 404
on this one route now surfaces a typed AnnouncementNotFound error
that authed_json does not report to Sentry, and
announcements::ops::get_latest_announcement degrades it to a null
result matching the "no announcement" contract the caller already
documents. Any other failure (5xx, malformed response, session
expiry) still propagates and still reaches Sentry.

Fixes tinyhumansai#4401

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.

Pull request overview

Hardens the Rust client’s best-effort announcements fetch so that a backend 404 on GET /announcements/latest is treated as “no announcement” (null) instead of bubbling up as an error that gets reported to Sentry (previously double-reported via both authed_json and JSON-RPC dispatch).

Changes:

  • Introduces a typed BackendApiError::AnnouncementNotFound for scoped 404 handling on GET /announcements/latest.
  • Updates announcements ops to fold that typed 404 into Value::Null while preserving all other error propagation via flatten_authed_error.
  • Adds Rust tests validating the new typed error behavior and non-misclassification on adjacent paths.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/openhuman/announcements/ops.rs Intercepts typed announcement 404 and degrades to null to match the best-effort contract.
src/api/rest.rs Adds AnnouncementNotFound and emits it from authed_json for the specific announcements endpoint to avoid report_error noise.
src/api/rest_tests.rs Adds coverage for the new typed 404 behavior and ensures nearby paths aren’t misclassified.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/api/rest.rs Outdated
Comment thread src/api/rest_tests.rs
Copilot review on PR tinyhumansai#4417 flagged that the exact url.path() ==
"/announcements/latest" check would miss the route when the resolved
URL carries a base-path prefix (e.g. a BACKEND_URL override resolving
to /api/v1/announcements/latest), falling through to the generic
non-2xx report_error path this PR exists to avoid.

Mirror parse_message_path's existing sliding-window/suffix tolerance
(OPENHUMAN-TAURI-R7) with a new is_announcements_latest_path helper
that matches on the last two path segments instead of the full path.
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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: Pro

Run ID: 00a8df47-512e-4265-9c8a-9c517646fc6d

📥 Commits

Reviewing files that changed from the base of the PR and between f979bfa and f00b971.

📒 Files selected for processing (3)
  • src/api/rest.rs
  • src/api/rest_tests.rs
  • src/openhuman/announcements/ops.rs
 _________________________________________
< Time zones: the final boss of software. >
 -----------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

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.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

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.

Announcements 404 floods Sentry — best-effort fetch must degrade to null silently

2 participants