Skip to content

fix(dialectic): token-type-aware Anthropic auth — sk-ant-api → x-api-key (CLA-117) - #46

Merged
JuzzyDee merged 1 commit into
masterfrom
fix/dialectic-auth-cla117
Jun 16, 2026
Merged

JuzzyDee merged 1 commit into
masterfrom
fix/dialectic-auth-cla117

Conversation

@JuzzyDee

@JuzzyDee JuzzyDee commented Jun 16, 2026 •

Copy link
Copy Markdown
Owner

What

The nightly dialectic was the one scheduled Anthropic caller the CLA-117 token-type-aware auth migration missed. worker_dialectic.rs hardcoded Authorization: Bearer {token}, so once the secret became an sk-ant-api… key, every Stage 1 call got a flat 401 authentication_error: "Invalid bearer token".

Evidence (dialectic_runs)

  • 06-02/03/04: clean — decisions landing, errors 0–2
  • 06-14 & 06-15: 3/3 candidates errored, 0 decisions — all Anthropic API 401 … Invalid bearer token

encode, cscc, orient and adas already carry the token-type-aware block and were unaffected — only the dialectic was missed.

Fix

Mirror the exact block the other callers use:

if oauth_token.starts_with("sk-ant-api") {
    headers.set("x-api-key", &oauth_token)?;
} else {
    headers.set("Authorization", &format!("Bearer {}", oauth_token))?;
}

Verification

  • cargo check --target wasm32-unknown-unknown --lib — clean.
  • Already deployed; proof is tonight's 08:00 UTC dialectic run flipping errors_count 3 → 0 in dialectic_runs.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced API request authentication to properly support multiple token formats and credential types. The authentication layer now intelligently recognizes and handles different token types, automatically applying the correct authentication headers based on token characteristics. This ensures optimal compatibility, enhanced security, and reliable communication with backend services across various authentication scenarios.

…key (CLA-117)

The dialectic was the one scheduled Anthropic caller the CLA-117 migration
missed — it hardcoded `Authorization: Bearer`, so the sk-ant-api key 401'd
every Stage 1 call (06-14 / 06-15 runs: 3/3 errors). Mirror the token-type
block cscc/orient/encode already use.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d90d6ecb-04d7-4044-a49d-8b046f234a1e

📥 Commits

Reviewing files that changed from the base of the PR and between 46a58f0 and 1f61730.

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

📝 Walkthrough

Walkthrough

In haiku_tool_call, the authentication header for Anthropic Messages API requests is made token-type aware: tokens prefixed with sk-ant-api now use the x-api-key header, while all other tokens continue using the Authorization: Bearer header.

Changes

Token-type-aware auth header

Layer / File(s) Summary
Token-prefix-based header selection
src/worker_dialectic.rs
Replaces the unconditional Authorization: Bearer header with a conditional branch: tokens beginning with sk-ant-api set the x-api-key header, all others fall back to Authorization: Bearer.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 Hopping through headers, one key or two,
"sk-ant-api" gets its own special queue!
Bearer or x-api, the token decides,
A tiny branch where authentication hides.
No more one-size-fits-all — now each token's true! 🗝️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: implementing token-type-aware authentication for Anthropic API calls in the dialectic module, with specific detail about the sk-ant-api token format mapping to x-api-key header.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dialectic-auth-cla117

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 and usage tips.

@JuzzyDee
JuzzyDee merged commit 65c0b45 into master Jun 16, 2026
6 checks passed
@JuzzyDee
JuzzyDee deleted the fix/dialectic-auth-cla117 branch June 16, 2026 13:23
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