Skip to content

fix(proto): dedicated reject code for orgs with no cache (#302) - #308

Merged
DerDennisOP merged 1 commit into
mainfrom
fix/302-no-cache-reject-code
Jun 3, 2026
Merged

fix(proto): dedicated reject code for orgs with no cache (#302)#308
DerDennisOP merged 1 commit into
mainfrom
fix/302-no-cache-reject-code

Conversation

@DerDennisOP

Copy link
Copy Markdown
Member

Closes #302.

Problem

When a worker connected to a server whose organization had no subscribed cache, the handshake failed with a generic 401 Unauthorized. The token actually validated fine — the connection was refused only because the org has no cache — so 401 was misleading and gave no actionable reason.

Fix

decide_auth now distinguishes the two cases. When the worker authenticated (at least one token validated) but every authorized peer was demoted because its organization has no cache, the handshake is rejected with a dedicated 495 organization has no cache subscribed ("incomplete server setup"). A genuine token failure still returns 401 no valid peer tokens provided.

perform_auth computes emptied_by_missing_cache from the token-validation and cache-filter steps and threads it into the pure decide_auth policy function. The worker surfaces the code+reason verbatim, so the operator sees the real cause.

Tests (TDD)

  • auth_decision_tests::registered_emptied_by_missing_cache — new case asserting 495.
  • Existing decide_auth cases updated for the new parameter; registered_but_no_valid_token confirms genuine failures stay 401.

Docs

  • docs/src/development/proto.md — handshake description + error-code table (495).
  • docs/src/tests.md — updated reject behaviour and test inventory.

@DerDennisOP
DerDennisOP merged commit 43aaf7f into main Jun 3, 2026
10 checks passed
@DerDennisOP
DerDennisOP deleted the fix/302-no-cache-reject-code branch June 3, 2026 09:38
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.

Custom error code for uncompleted server setup

1 participant