Skip to content

fix(config): validate providers config entries — reject non-URL base, accept camelCase aliases#9359

Closed
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/providers-config-validation
Closed

fix(config): validate providers config entries — reject non-URL base, accept camelCase aliases#9359
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/providers-config-validation

Conversation

@luyao618

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes silent misconfiguration in providers: config entries that caused cryptic APIConnectionError and Bearer no-key-required failures.

Three issues are addressed:

  1. Non-URL strings silently accepted as base_url: The api field was checked first in the URL lookup order ("api", "url", "base_url"), and any non-empty string was accepted without URL validation. A value like openai-reverse-proxy would be used as the endpoint, causing Invalid URL errors at runtime.

  2. camelCase keys silently ignored: Hand-written configs using apiKey, baseUrl, etc. were silently dropped because only snake_case (api_key, base_url) was recognized. This left the provider with no credentials.

  3. Unknown keys unreported: Typos and unsupported fields in provider entries produced no warning, making config debugging difficult.

Related Issue

Fixes #9332

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • URL validation: Base URL candidates are now validated via urlparse() — must have both scheme and netloc. Non-URL strings are skipped with a clear warning naming the field and value.
  • URL field priority reordered: Changed from ("api", "url", "base_url") to ("base_url", "url", "api") so explicit base_url takes precedence.
  • camelCase aliases: Common camelCase keys (apiKeyapi_key, baseUrlbase_url, apiModeapi_mode, etc.) are auto-mapped with a deprecation warning.
  • Unknown key warnings: Unrecognized config keys are logged at WARNING level to surface typos early.
  • Logging setup: Added logging import and module-level logger to hermes_cli/config.py.

How to Test

  1. Create a provider entry with a non-URL api field:

    providers:
      nvidia:
        api: openai-reverse-proxy
        api_key: sk-test

    Before: Silently accepted, fails at runtime with Invalid URL.
    After: Entry is rejected at config load with a clear warning.

  2. Create a provider entry with camelCase keys:

    providers:
      myhost:
        baseUrl: https://api.example.com/v1
        apiKey: sk-test

    Before: Both keys silently ignored, no URL and no key found.
    After: Auto-mapped to base_url and api_key with deprecation warnings.

  3. Run the test suite:

    pytest tests/hermes_cli/test_provider_config_validation.py -v
  4. Run full suite:

    pytest tests/ -q --ignore=tests/integration --ignore=tests/e2e

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: macOS (Darwin 25.4.0, Apple Silicon), Python 3.11

Documentation & Housekeeping

  • Updated relevant documentation — or N/A
  • Updated cli-config.yaml.example — or N/A
  • Updated CONTRIBUTING.md or AGENTS.md — or N/A
  • Considered cross-platform impact — or N/A
  • Updated tool descriptions/schemas — or N/A

… accept camelCase aliases

_normalize_custom_provider_entry() silently accepted non-URL strings
(e.g. "openai-reverse-proxy") as base_url via the "api" field, and
ignored camelCase keys (apiKey, baseUrl) without warning.

Changes:
- Validate that base URL candidates have a scheme and netloc via
  urlparse; skip non-URL values with a clear warning
- Change URL field priority to (base_url, url, api) so explicit
  base_url takes precedence
- Accept common camelCase aliases (apiKey → api_key, baseUrl →
  base_url, etc.) with a deprecation warning
- Warn on unrecognized config keys to surface typos early

Fixes NousResearch#9332
teknium1 pushed a commit that referenced this pull request Apr 20, 2026
… accept camelCase aliases (#9332)

Cherry-picked from PR #9359 by @luyao618.

- Accept camelCase aliases (apiKey, baseUrl, apiMode, keyEnv, defaultModel,
  contextLength, rateLimitDelay) with auto-mapping to snake_case + warning
- Validate URL field values with urlparse (scheme + netloc check) — reject
  non-URL strings like 'openai-reverse-proxy' that were silently accepted
- Warn on unknown keys in provider config entries
- Re-order URL field priority: base_url > url > api (was api > url > base_url)
- 12 new tests covering all scenarios

Closes #9332
teknium1 pushed a commit that referenced this pull request Apr 20, 2026
… accept camelCase aliases (#9332)

Cherry-picked from PR #9359 by @luyao618.

- Accept camelCase aliases (apiKey, baseUrl, apiMode, keyEnv, defaultModel,
  contextLength, rateLimitDelay) with auto-mapping to snake_case + warning
- Validate URL field values with urlparse (scheme + netloc check) — reject
  non-URL strings like 'openai-reverse-proxy' that were silently accepted
- Warn on unknown keys in provider config entries
- Re-order URL field priority: base_url > url > api (was api > url > base_url)
- 12 new tests covering all scenarios

Closes #9332
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #12993 #12993 — your commit was cherry-picked onto current main with your authorship preserved. Thanks @luyao618!

@teknium1 teknium1 closed this Apr 20, 2026
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
… accept camelCase aliases (NousResearch#9332)

Cherry-picked from PR NousResearch#9359 by @luyao618.

- Accept camelCase aliases (apiKey, baseUrl, apiMode, keyEnv, defaultModel,
  contextLength, rateLimitDelay) with auto-mapping to snake_case + warning
- Validate URL field values with urlparse (scheme + netloc check) — reject
  non-URL strings like 'openai-reverse-proxy' that were silently accepted
- Warn on unknown keys in provider config entries
- Re-order URL field priority: base_url > url > api (was api > url > base_url)
- 12 new tests covering all scenarios

Closes NousResearch#9332
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
… accept camelCase aliases (NousResearch#9332)

Cherry-picked from PR NousResearch#9359 by @luyao618.

- Accept camelCase aliases (apiKey, baseUrl, apiMode, keyEnv, defaultModel,
  contextLength, rateLimitDelay) with auto-mapping to snake_case + warning
- Validate URL field values with urlparse (scheme + netloc check) — reject
  non-URL strings like 'openai-reverse-proxy' that were silently accepted
- Warn on unknown keys in provider config entries
- Re-order URL field priority: base_url > url > api (was api > url > base_url)
- 12 new tests covering all scenarios

Closes NousResearch#9332
Luminet2023 pushed a commit to Luminet2023/hermes-agent that referenced this pull request May 1, 2026
… accept camelCase aliases (NousResearch#9332)

Cherry-picked from PR NousResearch#9359 by @luyao618.

- Accept camelCase aliases (apiKey, baseUrl, apiMode, keyEnv, defaultModel,
  contextLength, rateLimitDelay) with auto-mapping to snake_case + warning
- Validate URL field values with urlparse (scheme + netloc check) — reject
  non-URL strings like 'openai-reverse-proxy' that were silently accepted
- Warn on unknown keys in provider config entries
- Re-order URL field priority: base_url > url > api (was api > url > base_url)
- 12 new tests covering all scenarios

Closes NousResearch#9332
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
… accept camelCase aliases (NousResearch#9332)

Cherry-picked from PR NousResearch#9359 by @luyao618.

- Accept camelCase aliases (apiKey, baseUrl, apiMode, keyEnv, defaultModel,
  contextLength, rateLimitDelay) with auto-mapping to snake_case + warning
- Validate URL field values with urlparse (scheme + netloc check) — reject
  non-URL strings like 'openai-reverse-proxy' that were silently accepted
- Warn on unknown keys in provider config entries
- Re-order URL field priority: base_url > url > api (was api > url > base_url)
- 12 new tests covering all scenarios

Closes NousResearch#9332
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
… accept camelCase aliases (NousResearch#9332)

Cherry-picked from PR NousResearch#9359 by @luyao618.

- Accept camelCase aliases (apiKey, baseUrl, apiMode, keyEnv, defaultModel,
  contextLength, rateLimitDelay) with auto-mapping to snake_case + warning
- Validate URL field values with urlparse (scheme + netloc check) — reject
  non-URL strings like 'openai-reverse-proxy' that were silently accepted
- Warn on unknown keys in provider config entries
- Re-order URL field priority: base_url > url > api (was api > url > base_url)
- 12 new tests covering all scenarios

Closes NousResearch#9332
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
… accept camelCase aliases (NousResearch#9332)

Cherry-picked from PR NousResearch#9359 by @luyao618.

- Accept camelCase aliases (apiKey, baseUrl, apiMode, keyEnv, defaultModel,
  contextLength, rateLimitDelay) with auto-mapping to snake_case + warning
- Validate URL field values with urlparse (scheme + netloc check) — reject
  non-URL strings like 'openai-reverse-proxy' that were silently accepted
- Warn on unknown keys in provider config entries
- Re-order URL field priority: base_url > url > api (was api > url > base_url)
- 12 new tests covering all scenarios

Closes NousResearch#9332
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]: providers: config entries silently ignore apiKey/baseUrl and accept non-URL strings as base_url via the api field

2 participants