Skip to content

auth-test --provider-profile ignores named OpenAI-compatible profile auth settings #402

Closed

Description

@abhinav93r

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 = 16000

SARVAM_API_KEY is set in the environment.

Repro

jcode provider current --provider-profile sarvam

Output:

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-105b

Observed 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:

  1. 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
  2. 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

  1. added
    bug
    priority: medium
    autonomous: likely
    on Jun 24, 2026
  2. 1jehuang commented on Jun 24, 2026

    @1jehuang
    Owner

    Deep triage — root cause confirmed.

    The divergence is between the runtime path and the auth-test credential probe:

    • Runtime (jcode run --provider-profile sarvam) resolves the named [providers.sarvam] config via apply_named_provider_profile_env_from_config / apply_named_provider_profile_env (crates/jcode-base/src/provider_catalog.rs:639/644), which honors the profile's api_key_env (SARVAM_API_KEY) and auth_header. That's why it succeeds.
    • auth-test instead goes through generic_credential_paths_for_provider in src/cli/auth_test/probes.rs:24-27, where the OpenAiCompatible arm calls resolve_openai_compatible_profile(profile) and probes config_dir.join(resolved.env_file) — i.e. the built-in openai-compatible.env file path — rather than reading the named config profile's api_key_env from the environment. choice.rs similarly resolves via the built-in OpenAiCompatibleProfile table, 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_env env var (and auth_header/env_file from the [providers.<name>] block) instead of hardcoding the generic openai-compatible.env path. Autonomous: likely (clear root cause; small surface, but needs care to route named-config profiles through the same resolver as runtime).

  3. added
    triage: reproducible
    on Jun 25, 2026
  4. 1jehuang commented on Jun 25, 2026

    @1jehuang
    Owner

    Triage: reproducible. Confirmed root cause in src/cli/auth_test/probes.rs: the OpenAiCompatible(profile) arm of generic_credential_paths_for_provider (:24-27) calls resolve_openai_compatible_profile(profile) and probes config_dir.join(resolved.env_file) (the built-in openai-compatible.env), instead of reading the named [providers.<name>] block's api_key_env/auth_header. Runtime succeeds because jcode run --provider-profile resolves via apply_named_provider_profile_env* in crates/jcode-base/src/provider_catalog.rs (:639/644), which honors SARVAM_API_KEY and the custom header. Hence the false not_configured failure.

    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_env env var (and auth_header/env_file from [providers.<name>]) rather than the hardcoded generic env path. Keeping priority: medium.

  5. 1jehuang commented on Jun 25, 2026

    @1jehuang
    Owner

    Fixed in b96dfa47 (pending release). Built and tests pass on Linux. See commit message for the specific change for this issue.

  6. added
    triage: fixed-pending-release
    and removed
    triage: reproducible
    on Jun 25, 2026
  7. 1jehuang commented on Jun 28, 2026

    @1jehuang
    Owner

    Released in v0.32.0. Run jcode update to get it.

  8. removed
    triage: fixed-pending-release
    on Jun 28, 2026
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: likelybugpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions