Repository navigation
Description
Summary
Running jcode --provider-profile <name> auth-test outputs not_configured (or an auth failure) even when the specified provider profile is fully configured and working perfectly for inference.
This creates a severe diagnostic trap where users attempting to verify their custom gateway setups are actively misled into thinking their config.toml or .env files are broken, leading to hours of wasted debugging.
Root Cause
When executing the diagnostic probe, the CLI accidentally clears the explicitly requested profile name from the environment, causing the probe to fall back to testing the built-in generic compatibility slot instead of the user's custom profile.
- In
src/cli/auth_test/run.rs:126, theauth-testcommand callsapply_login_provider_profile_envto prepare the environment for the probe. - That function invokes
force_apply_openai_compatible_profile_env(located incrates/jcode-base/src/provider_catalog.rs). - Inside
force_apply_openai_compatible_profile_env(lines 583-605),JCODE_NAMED_PROVIDER_PROFILEis explicitly listed in the environment variables array and deleted viacrate::env::remove_var(var). - As a result, the subsequent authentication probe evaluates the built-in
openai-compatiblestate rather than the named profile the user passed via--provider-profile.
(Note: Issue #402 previously touched this area and corrected the display path formatting in the auth-test output, but completely missed the fact that the underlying probe target was being wiped.)
Expected Behavior
auth-test should test the exact profile specified by the user and accurately report its configured status, matching the behavior of actual inference requests.
Proposed Fix
Ensure that apply_login_provider_profile_env (or the underlying force_apply method) preserves JCODE_NAMED_PROVIDER_PROFILE when evaluating an explicit --provider-profile target during an auth-test invocation.
Activity
1jehuang commentedon Aug 2, 2026
Confirmed, and your root-cause walk was exactly right, down to the line numbers.
apply_login_provider_profile_envcalledforce_apply_openai_compatible_profile_envon every path, and that function listsJCODE_NAMED_PROVIDER_PROFILEamong the vars it deletes. So the probe ran against the built-in generic openai-compatible slot instead of the profile you passed, and reportednot_configuredfor a profile that works fine for inference. Agreed that this is a bad failure mode: it points users at config that was never broken.Fixed: an explicitly selected named profile now short-circuits that function. This matches the precedence the explicit
--providerinit path already applied ("named provider profiles still take precedence when explicitly configured"), so the rule is now consistent across both paths rather than only one.The regression test asserts that both
JCODE_NAMED_PROVIDER_PROFILEand the profile's runtime env survive the probe setup.Commit:
40ec8fe70--- — Jcode agent (automated triage), on behalf of @1jehuang
1jehuang commentedon Aug 2, 2026
Fix is up for review in #727.
--- — Jcode agent (automated triage), on behalf of @1jehuang
1jehuang commentedon Aug 2, 2026
Verified end-to-end on built binaries, and the result confirms your report exactly.
Setup: a
[providers.company-gateway]profile inconfig.tomlwith its API key exported, then your command.Pre-fix binary:
Post-fix binary (same config, same command):
So the false negative you described is gone: a configured, working profile now reports as configured instead of sending you to debug a config that was never broken.
One residual issue worth flagging, found while verifying this. The probe now evaluates the right thing, but the reporting is still generic: the header says
auth-test: openai-compatibleand namesOPENAI_COMPAT_API_KEYrather thancompany-gatewayand its ownapi_key_env. So the pass/fail verdict is now correct, but the label does not yet tell you which profile produced it.That is a display bug rather than the diagnostic trap you reported, and fixing it means threading the profile identity into the report rendering, which is a larger change than this one. I have left it out of this fix rather than quietly bundling it. Happy to file it as a separate issue if you would find that useful.
Commit:
40ec8fe70, shipping in #727.--- — Jcode agent (automated triage), on behalf of @1jehuang
fix(auth-test): name the provider profile in the report, not the runt…
1jehuang commentedon Aug 2, 2026
Closing the loop on the residual issue I flagged above: it is now fixed too, so nothing is left outstanding here.
Both the report header and the credential line now name the profile you selected:
Previously (after the probe fix but before this) it still read
auth-test: openai-compatible/OpenAI-compatible auth status ..., so the verdict was correct but not attributable to a target, which was most of what made the original diagnosis so slippery.Verified builtin providers are unaffected, including while a profile is set (
auth-test: deepseekstill reports asdeepseek). The regression test fails if the label falls back to the runtime slot.Commits:
40ec8fe70(probe target),f1eabfb91(reporting).--- — Jcode agent (automated triage), on behalf of @1jehuang
fix(auth-test): keep an explicit named provider profile when probing (f…
chore: sync fork with upstream (224 behind), preserve fork commits (#2)
fix(auth-test): keep an explicit named provider profile when probing (f…
fix(auth-test): name the provider profile in the report, not the runt…
fix(auth-test): keep an explicit named provider profile when probing (f…
fix(auth-test): name the provider profile in the report, not the runt…
fix(auth-test): keep an explicit named provider profile when probing (f…
fix(auth-test): name the provider profile in the report, not the runt…
fix(auth-test): keep an explicit named provider profile when probing (f…
fix(auth-test): name the provider profile in the report, not the runt…
fix(auth-test): keep an explicit named provider profile when probing (f…
fix(auth-test): name the provider profile in the report, not the runt…
fix(auth-test): keep an explicit named provider profile when probing (f…
fix(auth-test): name the provider profile in the report, not the runt…
Triage batch: fixes for 1jehuang#712, 1jehuang#715, 1jehuang#719, 1je…