Skip to content

fix: allow Alibaba/Qwen Token Plan usage on Linux with a manual cookie#2356

Open
OfficialAbhinavSingh wants to merge 1 commit into
steipete:mainfrom
OfficialAbhinavSingh:fix-alibabatokenplan-linux-manual-cookie
Open

fix: allow Alibaba/Qwen Token Plan usage on Linux with a manual cookie#2356
OfficialAbhinavSingh wants to merge 1 commit into
steipete:mainfrom
OfficialAbhinavSingh:fix-alibabatokenplan-linux-manual-cookie

Conversation

@OfficialAbhinavSingh

Copy link
Copy Markdown
Contributor

Summary

sourceModeRequiresWebSupport blanket-rejects web-source providers off macOS, but it already carries per-provider escape hatches for opencodego, commandcode, cursor, and qoder when their cookie source is manual — those fetches are plain URLSession + cookies, and only browser cookie auto-import actually needs macOS.

alibabatokenplan (Alibaba / Qwen Cloud Token Plan) was missing this exemption, so on Linux:

$ codexbar usage --provider alibaba-token-plan
Error: selected source requires web support and is only supported on macOS.

…even with cookieSource: "manual" + a configured cookie header. AlibabaTokenPlanProviderSettings already conforms to ProviderCookieSettings, so the same exemption applies cleanly.

This is the "Blocker on Linux" from #2328 (the full Qwen Cloud Personal API variant is a separate, larger follow-up).

Fix

if provider == .alibabatokenplan,
   settings?.alibabaTokenPlan?.cookieSource == .manual
{
    return false
}

Placed alongside the existing commandcode / qoder exemptions (not #if os(Linux)-gated, since a manual cookie works on any platform; only cursor's app-auth path is Linux-specific). No effect on macOS (already supports web). Only .manual is exempted — .auto / .off still require web support.

Test

TestsLinux/AlibabaTokenPlanLinuxTests.swift:

  • cookieSource == .manual → does not require web support (reachable on Linux)
  • cookieSource == .auto → still requires web support (unchanged)

Proof (real run)

Runs on CI in the build-linux-cli "Swift Test (Linux only)" step. Local red→green in swift:6.3.3:

Before the fix (exemption removed) — manual cookie is still gated:

✘ "manual cookie source does not require macOS web support"  FAILED  (sourceModeRequiresWebSupport → true)
✔ "auto cookie source still requires web support off macOS"  passed
✘ Test run with 2 tests failed with 1 issue.

After the fix — both pass:

✔ "manual cookie source does not require macOS web support" passed
✔ "auto cookie source still requires web support off macOS" passed
✔ Test run with 2 tests in 1 suite passed

Build clean, swiftlint --strict 0 violations, swiftformat --lint clean.

Small and self-contained — happy to adjust or close if not wanted.

sourceModeRequiresWebSupport blanket-rejects web-source providers off
macOS, but carries per-provider escape hatches for opencodego,
commandcode, cursor, and qoder when their cookie source is manual - the
fetch is plain URLSession + cookies, only browser auto-import needs
macOS. alibabatokenplan was missing this exemption, so
codexbar usage --provider alibaba-token-plan failed on Linux even with a
manually configured cookie header. Add the same exemption. Part of steipete#2328.
@clawsweeper

clawsweeper Bot commented Jul 20, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix: allow Alibaba/Qwen Token Plan usage on Linux with a manual cookie This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@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: 5f2194445d

ℹ️ 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 +697 to +699
if provider == .alibabatokenplan,
settings?.alibabaTokenPlan?.cookieSource == .manual
{

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 Honor environment-provided Alibaba cookies

When users supply the supported ALIBABA_TOKEN_PLAN_COOKIE override instead of saving cookieSource: manual in config, this gate still returns true on Linux and rejects the request before AlibabaTokenPlanWebFetchStrategy.isAvailable can accept the env cookie. Include AlibabaTokenPlanSettingsReader.cookieHeader(environment:) != nil in this exemption so env-only manual cookies are not still reported as macOS-only.

Useful? React with 👍 / 👎.

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