Skip to content

feat(providers): manage provider headers via PATCH and ocx provider edit --headers (#959) - #1033

Merged
lidge-jun merged 4 commits into
devfrom
codex/lane-11-provider-headers
Aug 5, 2026
Merged

feat(providers): manage provider headers via PATCH and ocx provider edit --headers (#959)#1033
lidge-jun merged 4 commits into
devfrom
codex/lane-11-provider-headers

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Bug-stack campaign lane (devlog/_plan/260805_bug_stack_campaign/120). Fixes #959. Adopts PR #961 with contributor authorship preserved plus one hardening slice.

From #961 (Yuxin-Qiao, carried commits):

  • PATCH /api/providers accepts headers: shallow case-insensitive merge, null/{} clear, registry static-header preservation, mutation-lock replay, validation reuse (credential headers stay rejected).
  • ocx provider edit --headers with argument redaction; docs in five locales.

Hardening on top:

  • GET /api/providers exposes hasHeaders (presence only) — header names/values never leave the process; a sentinel serialization test pins GET and PATCH responses.

  • tests/management-provider-validation + cli-headless-parity 61/61; bun run typecheck 0 errors; bun run privacy:scan pass; full suite on ssh lidge 8314/0 (campaign tree).

Closes #961.

Yuxin-Qiao and others added 3 commits August 5, 2026 07:34
PATCH /api/providers now accepts a headers field, shallow-merged onto the existing block (null or {} clears it), and ocx provider edit gains --headers <json>. Custom providers such as Agent Router can restore required fingerprint headers through the management plane instead of hand-editing config.json. POST /api/providers already round-trips headers; validation reuses providerHeadersConfigError.
- redact --headers values from CLI usage errors so tokens never hit stderr (P1)
- merge header blocks case-insensitively so a casing-only PATCH replaces the
  existing key instead of leaving a combined duplicate for Headers (P2)
- restore registry static headers when clearing custom headers so transports
  like opencode-free keep their client marker (P2)
- re-apply the field mask under the config mutation lock immediately before
  saving so concurrent PATCHes merge instead of clobbering each other (major)
- regression tests for redaction, casing merge, static-header clear, and
  concurrent PATCH persistence
…nly (#959)

Adopts PR #961's headers management (authorship preserved) with one
hardening slice: the providers list reports whether a provider has
custom headers but never their names or values, with a sentinel
serialization test.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@lidge-jun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 05be5c51-fb5f-4fef-bd25-75584644c7f6

📥 Commits

Reviewing files that changed from the base of the PR and between 2a72aa4 and 870f477.

📒 Files selected for processing (15)
  • docs-site/src/content/docs/ja/reference/cli/providers-accounts.md
  • docs-site/src/content/docs/ja/reference/management-api.md
  • docs-site/src/content/docs/ko/reference/cli/providers-accounts.md
  • docs-site/src/content/docs/ko/reference/management-api.md
  • docs-site/src/content/docs/reference/cli/providers-accounts.md
  • docs-site/src/content/docs/reference/management-api.md
  • docs-site/src/content/docs/ru/reference/cli/providers-accounts.md
  • docs-site/src/content/docs/ru/reference/management-api.md
  • docs-site/src/content/docs/zh-cn/reference/cli/providers-accounts.md
  • docs-site/src/content/docs/zh-cn/reference/management-api.md
  • src/cli/provider-runtime.ts
  • src/cli/runtime-api.ts
  • src/server/management/provider-routes.ts
  • tests/cli-headless-parity.test.ts
  • tests/management-provider-validation.test.ts

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

@github-actions github-actions Bot added the enhancement New feature or request label Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2640c44cfe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +195 to +199
for (const [key, value] of Object.entries(next.headers ?? {})) {
if (!incoming.has(key.toLowerCase())) merged[key] = value;
}
for (const [key, value] of incoming.values()) merged[key] = value;
next.headers = merged;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve registry static headers when merging custom headers

When a registry provider whose transport relies on staticHeaders is configured normally (for example opencode-free), the saved config has those headers stripped and enrichProviderFromRegistry only re-adds them while prov.headers is absent. This merge starts from next.headers ?? {}, so PATCH /api/providers?name=opencode-free with { "headers": { "X-Trace": "v" } } persists only the user header; subsequent requests no longer include the required x-opencode-client marker and can be rejected or handled as the wrong upstream tier. Seed or merge the matching registry static headers before adding user-managed headers, or make derivation merge static headers into an existing header block.

AGENTS.md reference: src/AGENTS.md:L18-L18

Useful? React with 👍 / 👎.

Comment on lines +186 to +187
const headersError = providerHeadersConfigError(headersValue);
if (headersError) return { error: headersError };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Redact header names from validation errors

When users pass valid JSON through the new --headers/PATCH path but one value is invalid, e.g. {"X-Token":42}, this returns providerHeadersConfigError verbatim; that helper includes the header name in some messages, and runtimeRequest prints the management error to stderr. The CLI redacts parse errors because header names/values can identify tokens or accounts, so this PATCH validation should return a generic/redacted header error instead of echoing the name.

AGENTS.md reference: src/AGENTS.md:L20-L20

Useful? React with 👍 / 👎.

Comment on lines +411 to +416
if (replay.editorTouched) {
const syncError = providerManagementConfigError(name, replay.next);
if (syncError) {
replayError = syncError;
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Re-run DNS destination checks after replaying provider PATCH

When a PATCH awaits the async destination probe, another provider PATCH can commit a different baseUrl/allowPrivateNetwork before this lock-scoped replay. These lines only rerun synchronous validation on the recombined provider, so an update that was safe with allowPrivateNetwork:true can race with a separately validated allowPrivateNetwork:false PATCH and persist a hostname that resolves to private space without the opt-in; that hostname case is caught only by providerDestinationResolvedError, which no longer runs after replay. Re-run the resolved destination check for the replayed provider, or fail/retry if destination-related fields changed.

AGENTS.md reference: src/AGENTS.md:L20-L20

Useful? React with 👍 / 👎.

#1033 review blocker. The validator already rejects standard credential header
names and points at apiKey/authMode, but nothing said so where a user would
read it, and a code comment claimed header values 'may contain tokens' — which
reads as sanction for exactly the use the validator refuses.

Documents the contract in all five locales: --headers is non-secret request
metadata; an arbitrary name like X-My-Token cannot be recognized by the
validator, so the boundary is the user's to respect; and names the two concrete
exposures (the JSON is argv, so it reaches shell history and the process list
before any redaction runs, and header values persist in config.json in
cleartext unlike API keys). The comment is corrected to say the entry is
defensive rather than a supported credential channel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants