Skip to content

resolve_model_provider raises AttributeError when a legacy custom_providers row has a non-string name #9328

Backlog

Description

@nesquena-hermes

What happens

resolve_model_provider() raises AttributeError: 'int' object has no attribute 'strip' when a legacy custom_providers row has a non-string name (for example name: 5 in YAML). The model and base_url fields have the same pattern.

The failing reads are in the legacy-row loop, api/config.py:3720-3722 on master d49955dce91f:

entry_model = (entry.get('model') or '').strip()
entry_name = (entry.get('name') or '').strip()
entry_base_url = (entry.get('base_url') or '').strip()

api/config.py:3682 reads model the same way.

Reproduction

Config:

model: {provider: "openrouter:eu", default: gpt-x}
custom_providers:
  - {name: 5, base_url: "https://eu-proxy.example/v1"}
Call v0.52.741 master
resolve_model_provider("gpt-x") resolves resolves
resolve_model_provider("@openrouter:gpt-x") / ("@custom:gpt-x") AttributeError AttributeError
set_hermes_default_model("gpt-x", provider="openrouter:eu") saves AttributeError

The resolver bug isn't new. Since v0.52.742, though, the default-model save reaches it: when the provider id isn't declared, the save resolves the model with an @<built-in>: hint and hits the loop. The Agent's own legacy-row reader skips a row whose name or base_url isn't a string.

Fix shape

In those reads, treat a non-string value as absent, e.g. str(entry.get('name') or '').strip() only when it's a str, otherwise ''. That skips the row the way the Agent does. Add a test with a non-string name, model and base_url through resolve_model_provider() and set_hermes_default_model().

Found during the #9324 regression gate. It's out of scope for #9324.

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

    buglane-follow-up

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions