Skip to content

fix(api): delete custom models stored with legacy model_type values - #39708

Merged
crazywoola merged 2 commits into
langgenius:mainfrom
Souravrajvi0:fix/39559-delete-legacy-model-type
Jul 30, 2026
Merged

crazywoola merged 2 commits into
langgenius:mainfrom
Souravrajvi0:fix/39559-delete-legacy-model-type

Conversation

@Souravrajvi0

Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

After upgrading from 1.14 to 1.15+, custom model rows may still store legacy model_type values (text-generation / embeddings / reranking). Listing works because EnumText normalizes those values on read, but delete looked up the canonical values (llm / text-embedding / rerank), found no row, returned success, and left the model visible.

  • Add _model_type_db_values() using ModelType.to_origin_model_type() so queries match both canonical and legacy aliases.
  • Use that filter in custom model / credential / model-setting lookups used by delete flows.

Fixes #39559

Screenshots

Not applicable (backend delete/query fix).

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran the relevant backend unit tests for provider configuration delete/lookup (4 passed)

After 1.14→1.15 upgrades, provider_models rows may still store
text-generation/embeddings/reranking. Deletes sent llm/text-embedding/rerank
and silently no-oped. Match both canonical and origin aliases in lookups.

Fixes langgenius#39559
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 28, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 29, 2026
@crazywoola
crazywoola enabled auto-merge July 29, 2026 12:31
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-07-30 00:58:29.566657989 +0000
+++ /tmp/pyrefly_pr.txt	2026-07-30 00:58:20.694568760 +0000
@@ -4416,16 +4416,18 @@
     --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1036:31
 ERROR Argument `SimpleNamespace` is not assignable to parameter `credential_record` with type `ProviderCredential | ProviderModelCredential` in function `core.entities.provider_configuration.ProviderConfiguration._update_load_balancing_configs_with_credential` [bad-argument-type]
     --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1055:27
+ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
+    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1190:12
 ERROR `None` is not subscriptable [unsupported-operation]
-    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1171:12
+    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1206:12
 ERROR `None` is not subscriptable [unsupported-operation]
-    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1172:12
+    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1207:12
 ERROR `None` is not subscriptable [unsupported-operation]
-    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1188:12
+    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1223:12
 ERROR `None` is not subscriptable [unsupported-operation]
-    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1702:12
+    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1737:12
 ERROR `None` is not subscriptable [unsupported-operation]
-    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1894:12
+    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:1929:12
 ERROR Object of class `ModuleType` has no attribute `MockExtension` [missing-attribute]
   --> tests/unit_tests/core/extension/test_extensible.py:62:9
 ERROR Cannot index into `OrderedDict[str, ModuleExtension]` [bad-index]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 56.46% 56.46% +0.00%
Strict coverage 55.97% 55.97% +0.00%
Typed symbols 36,871 36,874 +3
Untyped symbols 28,686 28,686 0
Modules 3091 3091 0

@crazywoola
crazywoola added this pull request to the merge queue Jul 30, 2026
Merged via the queue into langgenius:main with commit fdaa073 Jul 30, 2026
34 checks passed
fatelei pushed a commit that referenced this pull request Jul 30, 2026
…39708)

Co-authored-by: Crazywoola <100913391+crazywoola@users.noreply.github.com>
wylswz pushed a commit to wylswz/dify that referenced this pull request Jul 30, 2026
…anggenius#39708)

Co-authored-by: Crazywoola <100913391+crazywoola@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update to 1.15 can't remove old LLM model

2 participants