Skip to content

Fix Custom Provider sign-in against endpoints that reject empty model#13660

Merged
melissa-barca merged 2 commits into
mainfrom
bugfix/custom-provider-auth
May 20, 2026
Merged

Fix Custom Provider sign-in against endpoints that reject empty model#13660
melissa-barca merged 2 commits into
mainfrom
bugfix/custom-provider-auth

Conversation

@melissa-barca
Copy link
Copy Markdown
Contributor

@melissa-barca melissa-barca commented May 20, 2026

Fixes #13421 Fixes #13489

Custom Provider sign-in now validates against the user's configured model. When positron.assistant.models.overrides.customProvider has at least one entry, the validator sends the first entry's identifier as the model field on the test request to /chat/completions; otherwise it sends an empty string. A 404 response from the endpoint is logged as a warning and treated as a soft success - credentials are saved and the user can proceed. 401, 403, timeouts, and 5xx responses still hard-fail.

This unblocks Databricks serving-endpoints and other OpenAI-compatible providers (Moonshot/Kimi, etc.) whose /chat/completions route rejects requests without a real model.

Release Notes

New Features

  • N/A

Bug Fixes

Validation Steps

@:assistant

To reproduce against a Databricks workspace (or any provider whose /chat/completions rejects empty model strings):

  1. In settings.json, set:
    "positron.assistant.provider.customProvider.enable": true,
    "positron.assistant.models.overrides.customProvider": [
      { "name": "Databricks Claude", "identifier": "databricks-claude-sonnet-4-6" }
    ]
  2. Open Configure Model Providers, pick Custom Provider, enter base URL https://<workspace>.azuredatabricks.net/serving-endpoints and your PAT, and sign in.
  3. Sign-in succeeds.

Unit coverage in extensions/authentication/src/test/customProvider.test.ts - run with npm run test-extension -- -l authentication --grep validateCustomProviderApiKey.

The custom provider validator POSTed `{model: '', messages: []}` to
`/chat/completions`, which Databricks `serving-endpoints` and the
Moonshot/Kimi API reject with 404 (and the validator surfaced as
"Custom Provider endpoint not found"), blocking sign-in. Read the
first entry's identifier from `positron.assistant.models.overrides
.customProvider` and send it as the model; treat HTTP 404 as a soft
success (warns to the auth log channel and returns) so providers whose
`/chat/completions` shape diverges from the OpenAI canonical can still
sign in. 401/403/timeouts/5xx remain hard failures.

Refs #13421, #13489.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:assistant

readme  valid tags

@github-actions
Copy link
Copy Markdown

PETE's assessment 🧪

Verdict: Adequate -- the new extension-host test file directly exercises all three behavioral changes: override-model resolution, empty-model fallback, and the 404 soft-fail.

What changed

  • extensions/authentication/src/validation/customProvider.ts:21-35 -- new getCustomProviderModel() reads the first identifier from positron.assistant.models.overrides.customProvider
  • extensions/authentication/src/validation/customProvider.ts:73 -- validation request body now uses the resolved model string instead of hardcoded ''
  • extensions/authentication/src/validation/customProvider.ts:88-91 -- HTTP 404 changed from a hard CustomProviderValidationError to a log.warn + early return

Tests in this PR

  • extensions/authentication/src/test/customProvider.test.ts (new, 89 lines) -- extension-host Mocha suite with three cases:
    • sends empty model when no override is configured -- confirms body is {model: '', messages: []} when getConfiguration returns undefined
    • sends the first override identifier as the model -- stubs models.overrides.customProvider with a Databricks entry and verifies the identifier appears in the request body
    • soft-fails HTTP 404 with a warning -- asserts log.warn is called once with a message matching /Custom Provider/ and /404/, and no error is thrown

Existing coverage

Not applicable -- this is a new test file providing primary coverage for the changed module.

Suggested additions

None.


PETE (Positron Extreme Test Experiment) - LLM-based test-coverage advisor, in pilot. Triggers on PR open and on /recheck-tests comments. Wrong verdict? Add a /recheck-tests comment to this PR to re-run, or ping @jonvanausdeln.

@melissa-barca melissa-barca requested a review from timtmok May 20, 2026 15:17
Copy link
Copy Markdown
Contributor

@timtmok timtmok left a comment

Choose a reason for hiding this comment

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

LGTM

@melissa-barca melissa-barca merged commit 8269211 into main May 20, 2026
28 checks passed
@melissa-barca melissa-barca deleted the bugfix/custom-provider-auth branch May 20, 2026 18:39
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

2 participants