Skip to content

fix(observability): classify embedding API 401 'Invalid token' as SessionExpired (TAURI-RUST-4K5 regression)#2869

Merged
sanil-23 merged 1 commit into
tinyhumansai:mainfrom
sanil-23:fix/embedding-auth-failure-session-expired
May 28, 2026
Merged

fix(observability): classify embedding API 401 'Invalid token' as SessionExpired (TAURI-RUST-4K5 regression)#2869
sanil-23 merged 1 commit into
tinyhumansai:mainfrom
sanil-23:fix/embedding-auth-failure-session-expired

Conversation

@sanil-23
Copy link
Copy Markdown
Contributor

Summary

Fix the core::observability::tests::classifies_embedding_api_invalid_token_401_as_session_expired test that's been failing on every PR rebased onto current main.

Root cause

PR #2786 (commit 14ff92b2) introduced the is_embedding_backend_auth_failure matcher and the 4K5 wire-shape test, both targeting SessionExpired so the FE re-login prompt fires (alongside the 4P0 OpenHuman-backend variant).

PR #2830 (commit d578b57e, "demote expected-error Sentry buckets across embeddings, provider, memory-store, FS, and thinking-mode wire shapes") landed shortly after on a pre-#2786 base. Its merge:

The result: classifies_embedding_api_invalid_token_401_as_session_expired (added by #2786) panics on current main:

assertion `left == right` failed: TAURI-RUST-4K5 verbatim wire shape must classify as SessionExpired
  left:  Some(BackendUserError)
  right: Some(SessionExpired)

Verified reproducer: git checkout upstream/main && cargo test --lib core::observability::tests::classifies_embedding_api_invalid_token_401_as_session_expired fails.

What this PR changes

src/core/observability.rs only:

  1. One-char classifier fix — flip the is_embedding_backend_auth_failure arm's return from BackendUserError back to SessionExpired, the intent introduced by fix(observability): classify OpenHuman/Embedding/streaming backend 'Invalid token' 401 as SessionExpired (TAURI-RUST-4P0 + 4K5 + 1EE) #2786.
  2. Reconcile the older testclassifies_embedding_backend_auth_failure (TAURI-RUST-T) was asserting the pre-fix(observability): classify OpenHuman/Embedding/streaming backend 'Invalid token' 401 as SessionExpired (TAURI-RUST-4P0 + 4K5 + 1EE) #2786 behavior. Update it to expect SessionExpired, matching the design contract. Updated the doc-comment to cross-reference fix(observability): classify OpenHuman/Embedding/streaming backend 'Invalid token' 401 as SessionExpired (TAURI-RUST-4P0 + 4K5 + 1EE) #2786 and the companion 4K5 test.

Both tests share the same wire shapes (Embedding API error 401 Unauthorized: and Embedding API error (401 Unauthorized): + "error":"Invalid token"); now they classify consistently.

Impact

Unblocks every PR rebasing onto current main. Confirmed downstream:

Test plan

  • All 121 core::observability::tests::* pass locally (121 passed; 0 failed).
  • No other tests affected — the change only flips the kind returned for a wire shape that two tests already pin to a single expected value.
  • CI green on this PR before merge.

🤖 Generated with Claude Code

…sionExpired (TAURI-RUST-4K5 regression)

PR tinyhumansai#2786 (commit 14ff92b) added an `is_embedding_backend_auth_failure`
matcher that was supposed to classify the TAURI-RUST-4K5 wire shape
(`Embedding API error (401 Unauthorized): {"error":"Invalid token"}`)
as `SessionExpired` — to align with the 4P0 OpenHuman-backend variant
and surface a re-login prompt instead of a Sentry noise bucket.

A subsequent merge (tinyhumansai#2830 commit d578b57, 'demote expected-error
Sentry buckets across embeddings, provider, memory-store, FS, and
thinking-mode wire shapes') landed on a pre-tinyhumansai#2786 base and clobbered
the SessionExpired return back to BackendUserError. The
`classifies_embedding_api_invalid_token_401_as_session_expired` test
that tinyhumansai#2786 shipped therefore fails on every PR rebased onto current
`upstream/main`:

  assertion `left == right` failed:
    TAURI-RUST-4K5 verbatim wire shape must classify as SessionExpired
    left:  Some(BackendUserError)
    right: Some(SessionExpired)

Restore the intended return value. One-line fix to the
`is_embedding_backend_auth_failure` arm in `expected_error_kind`.
All observability tests pass.

Co-Authored-By: Claude <noreply@anthropic.com>
@sanil-23 sanil-23 requested a review from a team May 28, 2026 20:10
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

@sanil-23, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 22 minutes and 53 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e6d2da1-a40e-4463-af5f-3d2ec9a016c5

📥 Commits

Reviewing files that changed from the base of the PR and between e83bfd6 and 3b95e1a.

📒 Files selected for processing (1)
  • src/core/observability.rs

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

Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

@sanil-23 hey! the code looks good to me — clean regression fix with the right behavior restored. CI is still pending, so i'll hold off on approving until those are green. once everything passes, i'll come back and approve this. let me know if you need anything in the meantime.


What this fixes: The merge of #2830 onto a pre-#2786 base silently reverted is_embedding_backend_auth_failure from SessionExpired back to BackendUserError, breaking the 4K5 wire-shape test added by #2786. This PR restores the correct classification and reconciles the older test to match the established contract.

Diff: One classifier flip in expected_error_kind + one test update. Both tests now consistently assert SessionExpired for the 401/"Invalid token" wire shapes. The change is minimal, targeted, and well-documented.

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