Skip to content

fix(config): validate provider URLs and accept alias keys#9507

Closed
anthhub wants to merge 1 commit into
NousResearch:mainfrom
anthhub:fix/9332-provider-config-validation
Closed

fix(config): validate provider URLs and accept alias keys#9507
anthhub wants to merge 1 commit into
NousResearch:mainfrom
anthhub:fix/9332-provider-config-validation

Conversation

@anthhub

@anthhub anthhub commented Apr 14, 2026

Copy link
Copy Markdown

Summary

Tighten providers: normalization so invalid api strings are no longer silently treated as base_url, while camelCase aliases like apiKey, baseUrl, and apiMode continue to work with deprecation warnings.

Related Issue

Fixes #9332

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • Validate providers.* URL candidates before accepting them as base_url
  • Accept common camelCase aliases (apiKey, baseUrl, apiMode, etc.) and warn about deprecated field names
  • Reuse the same normalized provider view in runtime_provider so direct providers: resolution honors aliases, api_key, and api_mode
  • Add regression coverage for camelCase aliases and invalid non-URL api values

How to Test

  1. . venv/bin/activate
  2. python -m pytest tests/hermes_cli/test_config.py tests/hermes_cli/test_user_providers_model_switch.py tests/hermes_cli/test_runtime_provider_resolution.py -q
  3. Verify a providers: entry with baseUrl/apiKey resolves correctly and that a non-URL api: value is ignored with a warning

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

Documentation & Housekeeping

  • N/A — no docs/config example updates required for this bugfix

@anthhub anthhub force-pushed the fix/9332-provider-config-validation branch from b52114d to fa449dd Compare April 15, 2026 06:48
@anthhub

anthhub commented Apr 15, 2026

Copy link
Copy Markdown
Author

Rebased this PR onto the latest main and resolved the runtime-provider conflict.

Re-ran the focused regression coverage after the rebase:

  • python -m pytest tests/hermes_cli/test_config.py tests/hermes_cli/test_user_providers_model_switch.py tests/hermes_cli/test_runtime_provider_resolution.py -q
  • Result: 125 passed

This remains a single-purpose config/runtime-provider fix. Happy to adjust or split further if that would make review easier.

@teknium1

Copy link
Copy Markdown
Contributor

Closed in favor of PR #12993 #12993 which fixes the same issue. Your DRY refactor to have runtime_provider call the shared normalizer was the cleanest architecture — may follow up on that pattern. Thanks @anthhub!

@teknium1 teknium1 closed this Apr 20, 2026
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