Skip to content

fix(providers): validate bailian-coding-plan against the Token Plan host - #10634

Merged
diegosouzapw merged 2 commits into
release/v3.8.50from
fix/bailian-token-plan-validation-endpoint
Aug 18, 2026
Merged

diegosouzapw merged 2 commits into
release/v3.8.50from
fix/bailian-token-plan-validation-endpoint

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Problem

Adding a valid Alibaba Token Plan key to bailian-coding-plan fails in the dashboard with
"Invalid API key", even with Singapore selected. Reported by the operator on the .17 box.

The catalog entry is the personal Token Plan (providers/apikey/regional.ts → name
"Alibaba Token Plan"), but two code paths disagreed on where it lives:

Path Host Source
Inference (open-sse registry) token-plan.ap-southeast-1.maas.aliyuncs.com fixed in #10290
Key validation (dashboard) coding-intl.dashscope.aliyuncs.com ❌ still the retired Coding Plan host

validateBailianCodingPlanProvider maps 401/403 to "Invalid API key", so the legacy host's
rejection surfaced as a bad key — while the very same key served inference fine.

docs/providers/ALIBABA-QWEN-PROVIDER-FAMILIES.md already documents the Token Plan hosts
for this provider, so this aligns code to the documented contract.

Live verification (2026-08-18, real Token Plan key)

Host Result
coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1/messages 401 invalid_api_key
token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages 429 Throttling.AllocationQuota

The 429 is the positive signal: auth succeeded, only the weekly quota was spent. Validation
treats non-auth 4xx as valid, so the fixed path accepts the key.

Changes

  • ALIBABA_PROVIDER_ENDPOINTS["bailian-coding-plan"] → Token Plan hosts, both regions,
    keeping /apps/anthropic/v1 (registry format: "claude").
  • Retired presets stay recognized as presets. A connection saved before this fix carries the
    old URL in providerSpecificData.baseUrl; without this it would be read as a deliberate custom
    URL and stay pinned to the dead host, deaf to the region selector.
  • Media stays on DashScope AIGC. resolveAlibabaProviderMediaBaseUrl derived media from the
    chat root, so this change would have silently repointed every Bailian image/video call at a host
    that does not serve /api/v1/services/aigc/…. Media now has an explicit override.
  • Probe model qwen3-coder-plus → qwen3.7-max (the former belonged to the Coding Plan and is
    absent from BAILIAN_CODING_PLAN_MODELS); overridable via validationModelId.
  • PROVIDER_ENDPOINTS + DEFAULT_PROVIDER_BASE_URLS (dashboard placeholder) updated; pl mirror
    of the provider-families doc synced with the EN original.

Tests (TDD — RED before the fix)

New tests/unit/bailian-token-plan-endpoint-parity.test.ts (5 tests) pins validation and
inference to the same host, forbids the legacy host in every default, and guards both the
retired-preset migration and the custom-URL escape hatch. Sibling suites updated where they
pinned the old host (assertions unchanged — only the URL).

  • bailian-token-plan-endpoint-parity + alibaba-provider-regions + bailian-coding-plan-{provider,media} + provider-validation-specialty + executor-default-base + provider-translate-path-golden: 247 pass / 0 fail
  • check:docs-all, check:docs-sync, check:provider-consistency: PASS
  • Focused ESLint on changed files: clean (the 42 no-explicit-any in executor-default-base.test.ts are pre-existing and exactly match the frozen suppression count)

⚠️ base-red inherited: #9985 — typecheck:core fails on open-sse/services/compression/engines/omniglyphAdapter.ts, untouched by this PR.

The catalog entry is the personal Alibaba Token Plan, but the region map still
resolved the retired Coding Plan hosts. #10290 moved only the open-sse registry
(inference) to token-plan.ap-southeast-1.maas.aliyuncs.com, leaving the dashboard's
key validation pointed at coding-intl.dashscope.aliyuncs.com.

That host rejects Token Plan keys with 401, and validateBailianCodingPlanProvider
maps 401/403 to "Invalid API key" — so adding a working key failed at the modal
while the same key served inference fine. Verified live 2026-08-18 with a valid
key: legacy host 401 invalid_api_key, Token Plan host 429 quota (auth OK).

- point both regions of ALIBABA_PROVIDER_ENDPOINTS at the Token Plan hosts,
  matching what docs/providers/ALIBABA-QWEN-PROVIDER-FAMILIES.md already stated
- keep the retired hosts recognized as presets, so connections saved with the old
  URL still follow the region selector instead of being pinned to a dead host
- keep image/video generation on the DashScope AIGC hosts, which the Token Plan
  host does not serve
- probe with a model this plan actually serves (qwen3-coder-plus was Coding Plan)
CodeQL flags URL .includes() checks as js/incomplete-url-substring-sanitization.
The guard is an assertion, not a sanitizer, but comparing new URL().hostname is
strictly more precise anyway — same coverage, no substring pattern.
@diegosouzapw
diegosouzapw merged commit c164ed9 into release/v3.8.50 Aug 18, 2026
11 checks passed
@diegosouzapw
diegosouzapw deleted the fix/bailian-token-plan-validation-endpoint branch August 18, 2026 08:51
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…ost (cheaper-inference#10634)

* fix(providers): validate bailian-coding-plan against the Token Plan host

The catalog entry is the personal Alibaba Token Plan, but the region map still
resolved the retired Coding Plan hosts. cheaper-inference#10290 moved only the open-sse registry
(inference) to token-plan.ap-southeast-1.maas.aliyuncs.com, leaving the dashboard's
key validation pointed at coding-intl.dashscope.aliyuncs.com.

That host rejects Token Plan keys with 401, and validateBailianCodingPlanProvider
maps 401/403 to "Invalid API key" — so adding a working key failed at the modal
while the same key served inference fine. Verified live 2026-08-18 with a valid
key: legacy host 401 invalid_api_key, Token Plan host 429 quota (auth OK).

- point both regions of ALIBABA_PROVIDER_ENDPOINTS at the Token Plan hosts,
  matching what docs/providers/ALIBABA-QWEN-PROVIDER-FAMILIES.md already stated
- keep the retired hosts recognized as presets, so connections saved with the old
  URL still follow the region selector instead of being pinned to a dead host
- keep image/video generation on the DashScope AIGC hosts, which the Token Plan
  host does not serve
- probe with a model this plan actually serves (qwen3-coder-plus was Coding Plan)

* test(providers): compare parsed hostnames in the legacy-host guard

CodeQL flags URL .includes() checks as js/incomplete-url-substring-sanitization.
The guard is an assertion, not a sanitizer, but comparing new URL().hostname is
strictly more precise anyway — same coverage, no substring pattern.

---------

Co-authored-by: Xiangzhe <bakryun0718@proton.me>
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.

3 participants