Skip to content

fix: allow MiniMax usage on Linux with a configured API key - #2475

Merged
steipete merged 3 commits into
steipete:mainfrom
OfficialAbhinavSingh:fix-minimax-linux-api-key
Jul 29, 2026
Merged

fix: allow MiniMax usage on Linux with a configured API key#2475
steipete merged 3 commits into
steipete:mainfrom
OfficialAbhinavSingh:fix-minimax-linux-api-key

Conversation

@OfficialAbhinavSingh

Copy link
Copy Markdown
Contributor

Closes #2474.

Problem

On Linux, minimax fails even with an API key configured:

$ codexbar config enable --provider minimax
$ printf '%s' "$MINIMAX_API_KEY" | codexbar config set-api-key --provider minimax --stdin
$ codexbar --provider minimax --format json
"message" : "Error: selected source requires web support and is only supported on macOS."

MiniMaxProviderDescriptor advertises sourceModes: [.auto, .web, .api], so under Auto the CLI's
sourceModeRequiresWebSupport gate returns true purely because .web is in the list — the API
strategy never gets a chance to run. But minimax.api is kind: .apiToken, a plain HTTPS request
with Authorization: Bearer …: no WebKit, no cookie import, no JS.

Fix

Exempt Auto from the gate when a MiniMax API key actually resolves, mirroring the existing
credential exemptions in the same function (.factory reads FactorySettingsReader.apiKey,
.kimi reads ProviderTokenResolver.kimiAPIToken):

if provider == .minimax,
   sourceMode == .auto,
   environment.map({ MiniMaxAPISettingsReader.apiToken(environment: $0) != nil }) == true
{
    // The MiniMax API fetch is plain HTTPS + Bearer auth; only its web/cookie path
    // needs macOS, so a configured API key works off macOS too.
    return false
}

MiniMaxAPISettingsReader.apiToken covers both MINIMAX_API_KEY and MINIMAX_CODING_API_KEY, and
ProviderConfigEnvironment.directAPIKeyEnvironmentKey maps .minimax to that same key — so keys
stored via config set-api-key are seen here too, not just environment variables.

Scope is deliberately narrow: explicit --source web and the no-credential case still require web
support, so nothing that genuinely needs macOS is bypassed.

Scope note

The issue also reports --source api failing. I could not reproduce that from source: the gate's
final switch already returns false for case .cli, .oauth, .api, so the explicit-API path should
not hit it. This PR therefore fixes only the Auto path, which is reproducible and covered below.

Validation

Built and tested on Linux in swift:6.3.3; macOS CI validates the rest.

Green — with the fix (4/4):

$ swift test --filter MiniMaxLinuxTests
◇ Suite MiniMaxLinuxTests started.
✔ Test "configured API key does not require macOS web support" passed after 0.001 seconds.
✔ Test "coding plan API key also skips the web-support gate" passed after 0.001 seconds.
✔ Test "explicit web source still requires web support even with an API key" passed after 0.001 seconds.
✔ Test "auto without an API key still requires web support off macOS" passed after 0.001 seconds.
✔ Test run with 4 tests in 1 suite passed after 0.003 seconds.

Red — same tests with the fix reverted (simulating current main):

$ swift test --filter MiniMaxLinuxTests
✘ Test "configured API key does not require macOS web support" recorded an issue at MiniMaxLinuxTests.swift:12:9:
  Expectation failed: !(CodexBarCLI.sourceModeRequiresWebSupport(.auto, provider: .minimax,
  environment: (… → ["MINIMAX_API_KEY": "sk-api-test"])) → true)
✘ Test "coding plan API key also skips the web-support gate" recorded an issue at MiniMaxLinuxTests.swift:22:9:
  Expectation failed: !(CodexBarCLI.sourceModeRequiresWebSupport(.auto, provider: .minimax,
  environment: (… → ["MINIMAX_CODING_API_KEY": "sk-cp-test"])) → true)
✔ Test "explicit web source still requires web support even with an API key" passed after 0.001 seconds.
✔ Test "auto without an API key still requires web support off macOS" passed after 0.003 seconds.
✘ Test run with 4 tests in 1 suite failed after 0.007 seconds with 2 issues.

Note the two negative controls pass in both states — they confirm the gate still fires for
explicit .web and for the no-credential case, so the exemption is scoped rather than a blanket
bypass.

Lint:

$ swiftlint --strict
Done linting! Found 0 violations, 0 serious in 1582 files.

Not tested: a live MiniMax account round-trip — I don't have MiniMax credentials. The issue
reporter already verified the endpoint answers on Linux via curl, and this change only affects
the CLI platform gate, not the request itself.

Competing open PR scan: none — no other open PR references #2474 or touches
sourceModeRequiresWebSupport.

@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: 07a76c8b9a

ℹ️ 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".

}
if provider == .minimax,
sourceMode == .auto,
environment.map({ MiniMaxAPISettingsReader.apiToken(environment: $0) != nil }) == true

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 Restrict the MiniMax bypass to API-fetchable keys

When MINIMAX_API_KEY contains a standard sk-api-... key, this condition now bypasses the non-macOS web-support gate, but MiniMax auto resolution does not actually run the API strategy for standard keys: MiniMaxProviderDescriptor.resolveStrategies returns only MiniMaxCodingPlanFetchStrategy for .standard, and MiniMaxAPIFetchStrategy.isAvailable also rejects .standard. On Linux that web strategy is unavailable without cookies, so users with the documented MINIMAX_API_KEY path fall through to No available fetch strategy instead of using HTTPS or being correctly gated; only coding-plan/unknown keys can safely skip this check.

Useful? React with 👍 / 👎.

@OfficialAbhinavSingh

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

The MiniMax descriptor advertises [.auto, .web, .api], so the CLI's
web-support gate rejected the provider under Auto on non-macOS hosts even
when an API key was configured. The MiniMax API fetch is plain HTTPS with
Bearer auth, so only its web/cookie path needs macOS.

Exempt Auto from the gate when an API key resolves, matching the existing
Factory and Kimi credential exemptions. Explicit --source web and the
no-credential case still require web support.

Closes steipete#2474
@steipete
steipete force-pushed the fix-minimax-linux-api-key branch from 07a76c8 to 7191cac Compare July 29, 2026 14:18
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 29, 2026, 10:43 AM ET / 14:43 UTC.

ClawSweeper review

What this changes

This PR refactors CodexBar’s non-macOS web-support gate, permits MiniMax Auto mode to bypass that gate only for key kinds that resolve to its HTTPS API strategy, and adds Linux regression tests.

Merge readiness

Blocked until real behavior proof from a real setup is added - 4 items remain

Keep this PR open: the maintainer corrected the original key-class bug and added a strategy-level regression test, but current main still has the Linux gate and this branch still needs redacted after-fix Linux CLI proof plus completion of the running required checks. citeturn2view0.

Priority: P2
Reviewed head: 4783dafdf0427175854b60ed8ebd9619d2a50090

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The corrected patch and targeted strategy coverage look solid, but real Linux behavior proof remains a merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body contains focused Linux test and lint output, but no redacted after-fix MiniMax CLI invocation with a real coding-plan credential showing successful usage retrieval; add terminal/live output without keys, account identifiers, or private endpoints before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body contains focused Linux test and lint output, but no redacted after-fix MiniMax CLI invocation with a real coding-plan credential showing successful usage retrieval; add terminal/live output without keys, account identifiers, or private endpoints before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current-main behavior: The current main implementation bases Auto-mode web support on whether the provider descriptor includes a web source, so MiniMax remains gated on non-macOS before this PR merges.
Maintainer-corrected key handling: Commit 4783dafd narrows the proposed MiniMax exemption after the maintainer established that standard sk-api- keys resolve only to the macOS coding-plan web path, while coding-plan and unknown-prefix keys can select the Linux-capable API strategy.
Regression coverage: The PR adds Linux-only tests covering coding-plan-key bypass, standard-key retention of the gate, explicit web mode, no-key Auto mode, and an API-strategy selection check.
Findings None None.
Security None None.

How this fits together

CodexBar’s CLI reads provider configuration and credentials, then decides whether an Auto source can run without macOS web support before selecting a usage-fetch strategy. This gate determines whether MiniMax proceeds to its API request path or reports that the selected source requires macOS.

flowchart LR
    Config[Provider config and API key] --> Gate[Non-macOS source gate]
    Source[Requested source mode] --> Gate
    Gate --> Planner[MiniMax strategy planner]
    Planner --> API[HTTPS API usage request]
    Planner --> Web[macOS web and cookie path]
    API --> Output[CLI usage output]
    Web --> Output
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body contains focused Linux test and lint output, but no redacted after-fix MiniMax CLI invocation with a real coding-plan credential showing successful usage retrieval; add terminal/live output without keys, account identifiers, or private endpoints before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The changed shared gate controls provider routing from persisted or environment-supplied credentials; an incorrect MiniMax key-kind classification could either block a valid Linux API route or open the gate only to fail later with no available strategy.
  • Resolve merge risk (P1) - The PR body provides focused tests and lint output, but no after-fix Linux CLI run with a real coding-plan credential showing that the command selects a usable API strategy and returns usage.
  • Resolve merge risk (P1) - The Linux build jobs remain in progress and macOS test jobs remain queued, so merge readiness cannot yet rely on complete required-check results.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch surface 2 files affected; 174 additions, 78 deletions A provider-specific fix also refactors the shared web-support gate, so the cross-provider behavior deserves review beyond the new Linux tests.
Linux regression coverage 5 focused tests added The suite covers both the intended coding-plan-key route and the standard-key, explicit-web, and no-key compatibility boundaries.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #2474
Summary: This PR is the active candidate fix for the related Linux MiniMax provider-routing report; it should remain open until the fix is proven and merged.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Prove the corrected Linux route before merge (recommended)
    Add a redacted Linux terminal transcript using a coding-plan MiniMax credential that shows the CLI completes through the API-capable path, then wait for the Linux and macOS required checks to finish green.
  2. Accept test-only evidence
    Maintainers may merge on the focused strategy-level tests alone, accepting that a real credentialed CodexBar CLI run has not yet demonstrated the corrected route.

Technical review

Best possible solution:

Land the narrow corrected exemption only after a redacted Linux CLI transcript demonstrates a coding-plan key reaches the MiniMax API path successfully and the required Linux/macOS checks pass; retain the gate for standard keys, explicit web mode, and missing credentials.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: current main’s Auto gate sees MiniMax’s web-capable descriptor and blocks Linux before strategy selection; the PR’s focused Linux tests encode the corrected key-kind cases. A live credentialed CodexBar run has not yet been supplied.

Is this the best way to solve the issue?

Yes, with the maintainer’s correction: exempting only credentials that resolve to the Linux-capable API strategy is narrower and safer than bypassing the gate for every MiniMax API key.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b7553b104158.

Labels

Label justifications:

  • P2: This is a bounded Linux provider-routing regression with a concrete corrective path, not a core-runtime outage.
  • merge-risk: 🚨 compatibility: The shared source gate affects existing MiniMax configurations and must preserve the standard-key and explicit-web behaviors during upgrade.
  • merge-risk: 🚨 auth-provider: The exemption depends on MiniMax credential kind and API-strategy availability, so incorrect classification changes provider authentication routing.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body contains focused Linux test and lint output, but no redacted after-fix MiniMax CLI invocation with a real coding-plan credential showing successful usage retrieval; add terminal/live output without keys, account identifiers, or private endpoints before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-main behavior: The current main implementation bases Auto-mode web support on whether the provider descriptor includes a web source, so MiniMax remains gated on non-macOS before this PR merges. (Sources/CodexBarCLI/CLIUsageCommand.swift:2955, b7553b104158)
  • Maintainer-corrected key handling: Commit 4783dafd narrows the proposed MiniMax exemption after the maintainer established that standard sk-api- keys resolve only to the macOS coding-plan web path, while coding-plan and unknown-prefix keys can select the Linux-capable API strategy. (Sources/CodexBarCLI/CLIUsageCommand.swift:676, 4783dafdf042)
  • Regression coverage: The PR adds Linux-only tests covering coding-plan-key bypass, standard-key retention of the gate, explicit web mode, no-key Auto mode, and an API-strategy selection check. (TestsLinux/MiniMaxLinuxTests.swift:1, 4783dafdf042)
  • Feature-history provenance: The branch history shows the original implementation in 7191cac2, followed by the complexity-preserving refactor in 9e8a2a85 and the key-class correction in 4783dafd; the latest two commits were authored by the current area contributor. (Sources/CodexBarCLI/CLIUsageCommand.swift:676, 4783dafdf042)
  • Maintainer review outcome: The maintainer explicitly verified the original bypass was unsafe for standard keys, pushed the correction and a pipeline-level test, and reported 119 focused tests across 17 suites; Linux and macOS CI jobs are still running or queued. (4783dafdf042)

Likely related people:

  • steipete: Authored the two follow-up commits that refactor the shared gate and narrow the MiniMax exemption to strategy-compatible key classes; also supplied the substantive review of the provider-routing behavior. (role: recent area contributor and correction author; confidence: high; commits: 9e8a2a854df2, 4783dafdf042; files: Sources/CodexBarCLI/CLIUsageCommand.swift, TestsLinux/MiniMaxLinuxTests.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add a redacted Linux terminal transcript showing a coding-plan credential completes a MiniMax usage request through the API-capable route.
  • Wait for the in-progress Linux builds and queued macOS tests to complete successfully.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-07-29T14:23:07.053Z sha 7191cac :: needs real behavior proof before merge. :: [P2] Restrict the bypass to API-capable MiniMax key classes
  • reviewed 2026-07-29T14:34:15.401Z sha 9e8a2a8 :: needs real behavior proof before merge. :: [P2] Gate the bypass on an available API strategy

@steipete

Copy link
Copy Markdown
Owner

Maintainer review — thanks @OfficialAbhinavSingh, this needed a correction before it could land, and I've pushed it rather than bouncing it back to you.

The defect: the exemption was applied to any configured MiniMax key, but MiniMaxAPIFetchStrategy.isAvailable explicitly refuses standard sk-api- keys. So under Auto, a standard key resolves to MiniMaxCodingPlanFetchStrategy — the macOS-only web path. On Linux the gate would open and the fetch would then fail with noAvailableStrategy, i.e. the same failure in a less obvious place. The exemption only actually holds for coding-plan (sk-cp-) and unknown-prefix keys, which do resolve to the plain HTTPS + Bearer API strategy.

What I changed (4783dafd): the exemption now additionally requires apiKeyKind != .standard, with a comment explaining why. Your first Linux test asserted the old behavior, so I inverted it to assert that a standard key still requires web support, and added a pipeline-level test that an exempted sk-cp- key really does resolve a Linux-capable strategy (minimax.api) — gate agreement alone wasn't proving the path works end to end.

I also pushed 9e8a2a85 earlier: your change tipped sourceModeRequiresWebSupport past the SwiftLint cyclomatic-complexity limit (it had grown one hand-written branch per provider), so I grouped the exemptions into webSupportExempt / cookieSourceExempt / credentialExempt helpers. Behavior-preserving — I compared every provider case against the pre-refactor version, and 119 focused tests across 17 suites pass.

Driving CI now; will land once green.

@OfficialAbhinavSingh

Copy link
Copy Markdown
Contributor Author

Thanks for pushing the correction rather than bouncing it back — it's the right fix.

I did read isAvailable gating on apiKeyKind, but never traced what that condition gated, so I never verified a strategy was actually reachable for the key class I was exempting, and my test then locked in the wrong behavior. Taking forward: assert the resolved pipeline contains the expected strategy id, not just the gate's boolean.

The complexity refactor makes sense too — that function was already close to the limit before I added another branch.

@steipete
steipete merged commit 77f2ea0 into steipete:main Jul 29, 2026
15 of 17 checks passed
@steipete

Copy link
Copy Markdown
Owner

Merged after full verification. MiniMax now works on Linux when a usable API credential is configured — scoped, after review, to keys that actually resolve a Linux-capable strategy: standard sk-api- keys still require the macOS web path because MiniMaxAPIFetchStrategy refuses them and Auto falls back to the Coding Plan page. Exempting those would only have moved the failure to noAvailableStrategy.

Includes a maintainer refactor grouping the CLI web-support exemptions into webSupportExempt / cookieSourceExempt / credentialExempt (your change tipped the function past the SwiftLint complexity limit), verified behavior-identical per provider, plus a pipeline-level regression proving an exempted key resolves minimax.api. The earlier macOS shard red was a 50-minute runner timeout, not a test failure. Thanks @OfficialAbhinavSingh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minimax provider fails on Linux — API-key path doesn't need WebKit but platform gate blocks it before pipeline (same root cause as #1596)

2 participants