Skip to content

Fix/claude refresh contract - #12

Merged
i1hwan merged 2 commits into
mainfrom
fix/claude-refresh-contract
Apr 12, 2026
Merged

i1hwan merged 2 commits into
mainfrom
fix/claude-refresh-contract

Conversation

@i1hwan

@i1hwan i1hwan commented Apr 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Describe the user-facing or operational change.

Related Issues

  • Closes #
  • Related to #

Validation

  • npm run lint
  • npm run test:unit
  • npm run test:coverage
  • Coverage is still >= 60% for statements, lines, functions, and branches
  • SonarQube PR analysis is green or any remaining issues are explicitly documented below

Tests Added Or Updated

  • List every changed or added automated test file.
  • If no production code changed, state that here.

Coverage Notes

  • If this PR changes src/, open-sse/, electron/, or bin/, explain which tests cover the change.
  • If coverage moved down in any touched file, explain why and what follow-up task will recover it.

Reviewer Notes

  • Call out any risky areas, migrations, feature flags, or manual validation that reviewers should know about.

i1hwan and others added 2 commits April 12, 2026 06:21
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Copilot AI review requested due to automatic review settings April 12, 2026 04:26
@i1hwan
i1hwan merged commit 8ab7f66 into main Apr 12, 2026
6 of 8 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the Claude OAuth refresh implementation in open-sse to better match the expected request contract and adds logging of redacted request metadata, with corresponding unit test updates.

Changes:

  • Added buildClaudeRefreshRequestMeta(...) and emitted a “request details” log entry during Claude token refresh.
  • Refactored refreshClaudeOAuthToken to reuse a headers object and log request metadata.
  • Updated unit tests to assert the emitted redacted request details and adjusted warning expectations.

Reviewed changes

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

File Description
open-sse/services/tokenRefresh.ts Adds Claude refresh request metadata builder and logs request details during refresh.
tests/unit/token-refresh-service.test.mjs Extends Claude refresh tests to validate logged request metadata and updated warning behavior.

bodyKeys: body instanceof URLSearchParams ? Array.from(body.keys()) : Object.keys(body || {}),
clientId: PROVIDERS.claude.clientId || null,
refreshTokenLength: typeof refreshToken === "string" ? refreshToken.length : 0,
hasProxyConfig: hasProxyConfig,

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

hasProxyConfig is populated with the full proxyConfig object (passed as the hasProxyConfig argument). Proxy config objects can include username/password, so this risks leaking proxy credentials into logs and also doesn’t match the field name (implies a boolean). Consider logging a boolean (e.g. !!proxyConfig) or a redacted proxy label (host:port only) instead of the raw object.

Suggested change
hasProxyConfig: hasProxyConfig,
hasProxyConfig: !!hasProxyConfig,

Copilot uses AI. Check for mistakes.
Comment on lines +252 to +256
log?.warn?.(
"TOKEN_REFRESH",
"Claude OAuth refresh request details",
buildClaudeRefreshRequestMeta(refreshToken, headers, params, proxyConfig)
);

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

This logs Claude refresh request details at warn level on every refresh attempt, including successful refreshes. That will likely create warning noise and may trigger alerting; it also makes it hard to distinguish actual warning conditions. Consider downgrading this to debug/info, and/or gating it behind an env flag so it can be enabled when diagnosing contract issues.

Copilot uses AI. Check for mistakes.
@@ -338,7 +354,7 @@ test("refreshClaudeOAuthToken returns null on invalid Claude refresh contract re
assert.equal(calls[0].options.headers["anthropic-beta"], "oauth-2025-04-20");
assert.equal(
log.entries.some((entry) => entry.level === "warn"),

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

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

The assertion log.entries.some((entry) => entry.level === "warn") === true is very broad and now effectively couples this test to “some warning happened”, which can become brittle as other warnings are added. Prefer asserting the specific expected warning entry (e.g., message "Claude OAuth refresh request details") rather than any warn-level log.

Suggested change
log.entries.some((entry) => entry.level === "warn"),
log.entries.some(
(entry) => entry.level === "warn" && entry.message === "Claude OAuth refresh request details"
),

Copilot uses AI. Check for mistakes.
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