Skip to content

fix: provider update silently drops model_type and endpoint_url#1628

Open
zhenjunchen-png wants to merge 1 commit into
eigent-ai:mainfrom
zhenjunchen-png:fix/provider-update-allow-model-type
Open

fix: provider update silently drops model_type and endpoint_url#1628
zhenjunchen-png wants to merge 1 commit into
eigent-ai:mainfrom
zhenjunchen-png:fix/provider-update-allow-model-type

Conversation

@zhenjunchen-png
Copy link
Copy Markdown

Related Issue

Closes #1627

Description

Fix ProviderService.update()'s _UPDATABLE_FIELDS whitelist so it matches the real Provider ORM field names. Before this fix, edits to model_type, endpoint_url, and encrypted_config via PUT /api/v1/provider/{id} were silently dropped — the request returned 200 OK but the DB row stayed unchanged.

Whitelist entry (before) Actual model field Result
api_base doesn't exist (real: endpoint_url) dead code
extra_config doesn't exist (real: encrypted_config) dead code
(missing) model_type silently rejected on update
(missing) endpoint_url silently rejected on update
(missing) encrypted_config silently rejected on update

The H10 security-by-design intent (whitelist instead of blanket update) is preserved; only the field names are corrected. Identity / audit fields (id, user_id, timestamps) are still excluded.

The pre-existing project-wide is_vaild typo (Provider.is_vaild, VaildStatus, etc.) is kept as-is — out of scope for this fix.

Testing Evidence (REQUIRED)

Repro on main before the fix and on this branch after the fix; diff between the two:

-_UPDATABLE_FIELDS = {"provider_name", "api_key", "api_base", "extra_config", "prefer", "is_vaild"}
+_UPDATABLE_FIELDS = {
+    "provider_name",
+    "api_key",
+    "model_type",
+    "endpoint_url",
+    "encrypted_config",
+    "prefer",
+    "is_vaild",
+}

Manual repro (described in #1627):

  1. Create a BYOK provider with model_type = claude-opus-4-6, set as default.
  2. Edit the card → change model_type to gpt-4o → Save.
  3. Before fix: GET /api/v1/providers shows the row still has model_type: "claude-opus-4-6"; agent runs continue using Claude.
  4. After fix: GET /api/v1/providers shows model_type: "gpt-4o"; agent runs use GPT-4o.

ruff check on the changed file reports the same 1 pre-existing I001 (import order) issue both before and after — this PR introduces 0 new lint findings.

  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

`ProviderService.update()`'s `_UPDATABLE_FIELDS` whitelist contained two
field names that don't exist on the `Provider` ORM model (`api_base` and
`extra_config`) while missing three that do (`model_type`, `endpoint_url`,
`encrypted_config`). Since the loop uses `setattr(model, key, value)`
without a `hasattr` check, the typo'd entries silently no-op'd and the
missing entries silently rejected legitimate updates from clients.

Symptom: editing a BYOK provider's model name and clicking Save (which
routes to PUT `/api/v1/provider/{id}`) appears to succeed (200 OK,
validation passes), but the database row keeps the old value and the
agent runtime continues using the previous model. Same for endpoint URL
edits.

Fix: replace the whitelist with the actual `Provider` field names (which
also match the `ProviderIn` request schema), and add a comment explaining
why the names must match verbatim.

The whitelist still excludes identity / audit fields (`id`, `user_id`,
timestamps) so the H10 security-by-design intent is preserved.

The pre-existing `is_vaild` typo is project-wide (`Provider.is_vaild`,
`VaildStatus`, etc.) and is kept as-is — out of scope for this fix.
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] PUT /api/v1/provider silently drops model_type, endpoint_url, encrypted_config

1 participant