Skip to content

[Bug] auth-test evaluates the wrong profile and false-negatives all custom named profiles #712

Closed

Description

@e-kotov

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.

  1. In src/cli/auth_test/run.rs:126, the auth-test command calls apply_login_provider_profile_env to prepare the environment for the probe.
  2. That function invokes force_apply_openai_compatible_profile_env (located in crates/jcode-base/src/provider_catalog.rs).
  3. Inside force_apply_openai_compatible_profile_env (lines 583-605), JCODE_NAMED_PROVIDER_PROFILE is explicitly listed in the environment variables array and deleted via crate::env::remove_var(var).
  4. As a result, the subsequent authentication probe evaluates the built-in openai-compatible state 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

  1. added
    bug
    priority: medium
    triage: reproducible
    autonomous: clear
    triage: fixed-pending-release
    on Aug 2, 2026
  2. 1jehuang commented on Aug 2, 2026

    @1jehuang
    Owner

    Confirmed, and your root-cause walk was exactly right, down to the line numbers.

    apply_login_provider_profile_env called force_apply_openai_compatible_profile_env on every path, and that function lists JCODE_NAMED_PROVIDER_PROFILE among the vars it deletes. So the probe ran against the built-in generic openai-compatible slot instead of the profile you passed, and reported not_configured for 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 --provider init 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_PROFILE and the profile's runtime env survive the probe setup.

    Commit: 40ec8fe70

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  3. 1jehuang commented on Aug 2, 2026

    @1jehuang
    Owner

    Fix is up for review in #727.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  4. 1jehuang commented on Aug 2, 2026

    @1jehuang
    Owner

    Verified end-to-end on built binaries, and the result confirms your report exactly.

    Setup: a [providers.company-gateway] profile in config.toml with its API key exported, then your command.

    Pre-fix binary:

    === auth-test: openai-compatible ===
    ✗ credential_probe — OpenAI-compatible auth status is not_configured (not configured).
    result: FAIL
    

    Post-fix binary (same config, same command):

    ✓ credential_probe — OpenAI-compatible auth status is available (API key ...).
    result: PASS
    

    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-compatible and names OPENAI_COMPAT_API_KEY rather than company-gateway and its own api_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

  5. 1jehuang commented on Aug 2, 2026

    @1jehuang
    Owner

    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:

    === auth-test: company-gateway (openai-compatible profile) ===
    ✓ credential_probe — company-gateway auth status is available (...)
    result: PASS
    

    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: deepseek still reports as deepseek). 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

  6. added a commit that references this issue on Aug 3, 2026
    40ec8fe
  7. added a commit that references this issue on Aug 5, 2026
    459b70f
  8. added 10 commits that reference this issue on Aug 30, 2026
    0cb6386
    f382a63
    1da447c
    d33dfed
    3bb4315
    4285ba3
    6edf618
    4430c1d
    07756fb
    ce89bd0
  9. added 2 commits that reference this issue on Sep 18, 2026
    0a8859e
    5f9d7cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugpriority: mediumtriage: fixed-pending-releasetriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions