Skip to content

AMI-15: Clearer error for a malformed Authorization header - #10

Merged
aminbaa merged 1 commit into
factory_pre_mergefrom
factory/AMI-15
Nov 28, 2026
Merged

aminbaa merged 1 commit into
factory_pre_mergefrom
factory/AMI-15

Conversation

@aminbaa

@aminbaa aminbaa commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Linear: https://linear.app/aminbaa/issue/AMI-15/clearer-error-for-a-malformed-authorization-header

Factory decision: build

Return a clear 401 naming Bearer <token> when the Authorization header is present but malformed, keep "Missing bearer token" when absent, and add WWW-Authenticate: Bearer to every 401.

Plan: In current_user (app/auth.py): no header gives the existing message; a present but non-Bearer <token> header gives a new 401 message saying the header must be Bearer <token>, without echoing the value.
Add WWW-Authenticate: Bearer headers to all 401s, including "Unknown token".
Add tests in tests/test_auth.py for the three criteria.
Open a PR on a branch and request review from @sagard-example/platform.

Why:

  • auth changes need the platform team's review (.github/CODEOWNERS)
  • approved by a person (used)
  • Requirements are specific, small and testable, confined to current_user in app/auth.py.
  • app/auth.py is owned by platform, but CONTRIBUTING only requires their review on the PR, which is a merge gate rather than a reason to escalate.
  • No personal data, money rules or policy decision is involved.
  • The earlier escalation comment was a pre-code safety check and the code confirms the scope is small.

Opened by ticket-factory. CI and review run on this PR; the factory lands it into factory_pre_merge when they pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@aminbaa
aminbaa merged commit 335c074 into factory_pre_merge Nov 28, 2026
2 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.

1 participant