Repository navigation
Description
Summary
jcode auth-test --provider-profile <name> appears to ignore the named profile's auth configuration for OpenAI-compatible profiles. It probes the generic openai-compatible.env credential path instead of the profile's configured api_key_env / auth header, causing a false auth failure even though runtime requests with the same provider profile succeed.
Version / platform
- jcode:
v0.31.2 (446be1d3) - OS: Windows
- Shell: PowerShell
Profile config
~/.jcode/config.toml:
[providers.sarvam]
type = "openai-compatible"
base_url = "https://api.sarvam.ai/v1"
auth = "header"
auth_header = "api-subscription-key"
api_key_env = "SARVAM_API_KEY"
default_model = "sarvam-105b"
requires_api_key = true
[[providers.sarvam.models]]
id = "sarvam-105b"
context_window = 16000SARVAM_API_KEY is set in the environment.
Repro
jcode provider current --provider-profile sarvamOutput:
requested_provider openai-compatible
resolved_provider sarvam
selected_model sarvam-105b
Runtime works with the same provider profile:
jcode run --provider-profile sarvam "Reply exactly: JCODE_SARVAM_OK"The request succeeds and returns:
JCODE_SARVAM_OK
But auth-test fails before runtime smoke because the credential probe checks the generic OpenAI-compatible provider instead of the profile:
jcode auth-test --provider-profile sarvam -m sarvam-105bObserved output:
=== auth-test: openai-compatible ===
credential paths:
- C:\Users\abhin\AppData\Roaming\jcode\openai-compatible.env
✗ credential_probe — OpenAI-compatible auth status is not_configured (not configured).
✓ refresh_probe — Skipped: provider does not expose a dedicated refresh probe in jcode today.
result: FAIL
Error: One or more auth tests failed
Expected
For a named OpenAI-compatible provider profile, auth-test should either:
- honor the profile-specific auth settings (
api_key_env = "SARVAM_API_KEY",auth = "header",auth_header = "api-subscription-key", profile-specific env file if configured), or - skip the generic OpenAI-compatible credential probe and rely on the actual runtime request path for that profile.
In this case, it should not require or check C:\Users\abhin\AppData\Roaming\jcode\openai-compatible.env because the selected profile is sarvam, not the generic openai-compatible profile.
Notes
This was initially discovered while testing Sarvam. Sarvam's deprecated sarvam-105b-32k model correctly failed at runtime and the API reported valid models as sarvam-30b and sarvam-105b; after switching to sarvam-105b, runtime works. The remaining problem is only the auth-test --provider-profile credential probe using the wrong credential source.
Activity
1jehuang commentedon Jun 24, 2026
Deep triage — root cause confirmed.
The divergence is between the runtime path and the auth-test credential probe:
jcode run --provider-profile sarvam) resolves the named[providers.sarvam]config viaapply_named_provider_profile_env_from_config/apply_named_provider_profile_env(crates/jcode-base/src/provider_catalog.rs:639/644), which honors the profile'sapi_key_env(SARVAM_API_KEY) andauth_header. That's why it succeeds.generic_credential_paths_for_providerinsrc/cli/auth_test/probes.rs:24-27, where theOpenAiCompatiblearm callsresolve_openai_compatible_profile(profile)and probesconfig_dir.join(resolved.env_file)— i.e. the built-inopenai-compatible.envfile path — rather than reading the named config profile'sapi_key_envfrom the environment.choice.rssimilarly resolves via the built-inOpenAiCompatibleProfiletable, not the user's[providers.<name>]config block.So the probe checks the wrong credential source and reports a false failure, even though the same profile authenticates fine at runtime.
Fix path: in the auth-test credential probe, when the selected provider is a named config profile, resolve credentials the same way the runtime does — check the configured
api_key_envenv var (andauth_header/env_filefrom the[providers.<name>]block) instead of hardcoding the genericopenai-compatible.envpath. Autonomous: likely (clear root cause; small surface, but needs care to route named-config profiles through the same resolver as runtime).1jehuang commentedon Jun 25, 2026
Triage: reproducible. Confirmed root cause in
src/cli/auth_test/probes.rs: theOpenAiCompatible(profile)arm ofgeneric_credential_paths_for_provider(:24-27) calls:639/644), which honorsresolve_openai_compatible_profile(profile)and probesconfig_dir.join(resolved.env_file)(the built-inopenai-compatible.env), instead of reading the named[providers.<name>]block'sapi_key_env/auth_header. Runtime succeeds becausejcode run --provider-profileresolves viaapply_named_provider_profile_env*incrates/jcode-base/src/provider_catalog.rs(SARVAM_API_KEYand the custom header. Hence the falsenot_configuredfailure.Fix path (autonomous: likely): when the selected provider is a named config profile, route the credential probe through the same resolver as runtime — check the configured
api_key_envenv var (andauth_header/env_filefrom[providers.<name>]) rather than the hardcoded generic env path. Keeping priority: medium.1jehuang commentedon Jun 25, 2026
Fixed in
b96dfa47(pending release). Built and tests pass on Linux. See commit message for the specific change for this issue.Fix several triaged GH issues (#369, #371, #373, #365, #374, #402)
1jehuang commentedon Jun 28, 2026
Released in v0.32.0. Run
jcode updateto get it.Fix several triaged GH issues (1jehuang#369, 1jehuang#371, 1jehuang#373…
Fix several triaged GH issues (1jehuang#369, 1jehuang#371, 1jehuang#373…