Skip to content

fix: validate openai-compatible base urls#329

Open
HwangJohn wants to merge 5 commits into
langchain-ai:mainfrom
HwangJohn:fix/openai-compatible-base-url-validation
Open

fix: validate openai-compatible base urls#329
HwangJohn wants to merge 5 commits into
langchain-ai:mainfrom
HwangJohn:fix/openai-compatible-base-url-validation

Conversation

@HwangJohn

Copy link
Copy Markdown
Contributor

Summary

  • validate provider base URLs before model construction
  • reject OpenAI-compatible URLs that point at /chat/completions instead of the API root
  • surface the same warning in credential diagnostics and interactive setup

Fixes #326.

Testing

  • corepack pnpm exec prettier --check src/constants.ts src/agent/index.ts src/credentials.tsx src/env.ts test/constants.test.ts test/env-behavior.test.ts
  • corepack pnpm run typecheck
  • corepack pnpm exec vitest run test/constants.test.ts test/env-behavior.test.ts (fails only on the existing Windows chmod assertion in test/env-behavior.test.ts > writes the env file with 0600 permissions; the new base URL tests pass)

@HwangJohn
HwangJohn marked this pull request as ready for review July 14, 2026 12:26

@colifran Colin Francis (colifran) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice one! Thanks HwangJohn!

@colifran

Copy link
Copy Markdown
Contributor

HwangJohn - can you take a look at the failing lint check and the failing test here?

@HwangJohn

Copy link
Copy Markdown
Contributor Author

Thanks for the heads up. I pushed a follow-up that merges the latest main, resolves the conflicts, and fixes the env-behavior test to use the dynamically imported env module.

Locally verified with:

  • corepack pnpm run lint:check
  • corepack pnpm run typecheck
  • corepack pnpm exec vitest run test/env-behavior.test.ts -t "flags an OpenAI-compatible chat completions endpoint as a base URL warning"
  • corepack pnpm exec vitest run test/constants.test.ts test/model-resolution.test.ts

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.

[Bug]: 404 error received after prompt attempt using Opencode provider

2 participants