You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Startup fails when legacy model_type "reranking" exists in DB: "'reranking' is not a valid ModelType'" #34471
I confirm that I am using English to submit this report, otherwise it will be closed.
【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
Please do not modify this template :) and fill in all the required fields.
Dify version
v1.13.3
Cloud or Self Hosted
Self Hosted (Docker), Self Hosted (Source)
Steps to reproduce
Start from an older Dify database that still contains legacy model_type = 'reranking' values.
Upgrade to current main and start the API.
During startup or when loading model-related records, Dify reads model_type from the database and tries to coerce it into the current ModelType enum.
The process fails with:
ValueError: 'reranking' is not a valid ModelType
From local investigation, this appears to happen because current code expects rerank, while older persisted data may still store reranking.
A minimal example is any model-related table row with a legacy model_type value such as reranking, for example in tables like:
- provider_models
- tenant_default_models
- provider_model_settings
- load_balancing_model_configs
- provider_model_credentials
✔️ Expected Behavior
Dify should remain backward-compatible with legacy persisted model type values such as reranking, and normalize them to the current enum value (rerank) instead of crashing during startup or
record loading.
❌ Actual Behavior
Dify crashes with:
ValueError: 'reranking' is not a valid ModelType
This prevents the service from starting correctly when older database records still contain the legacy enum value.
Additional context
ModelType.value_of() already accepts legacy aliases like reranking -> rerank, but some read paths still appear to use direct enum coercion and fail before normalization can happen.
This looks like a backward-compatibility regression for self-hosted upgrades with existing data.
A robust fix would be either:
1. normalize legacy enum values when reading from the database, and/or
2. add a migration that updates persisted model_type = 'reranking' to rerank.
This is the same class of regression reported in #34365, introduced by PR #34300 which changed the model_type column from String(40) to EnumText(ModelType). The EnumText.process_result_value() in api/models/types.py uses the direct enum constructor instead of calling ModelType.value_of(), so any legacy value that doesn't exactly match a current enum .value will crash [1].
Immediate workaround — run these SQL updates against your database to normalize reranking → rerank (and other known legacy values) across all affected tables:
UPDATE provider_models SET model_type ='rerank'WHERE model_type ='reranking';
UPDATE tenant_default_models SET model_type ='rerank'WHERE model_type ='reranking';
UPDATE provider_model_settings SET model_type ='rerank'WHERE model_type ='reranking';
UPDATE load_balancing_model_configs SET model_type ='rerank'WHERE model_type ='reranking';
UPDATE provider_model_credentials SET model_type ='rerank'WHERE model_type ='reranking';
You may also want to normalize the other known legacy aliases at the same time [2]:
-- repeat for each of the 5 tables aboveUPDATE<table>SET model_type ='text-embedding'WHERE model_type ='embeddings';
UPDATE<table>SET model_type ='llm'WHERE model_type ='text-generation';
The proper long-term fix (as noted in #34365) would be for the codebase to either add a data migration or update EnumText.process_result_value() to fall back to value_of() so legacy values are handled gracefully [3].
Activity
dosubot commentedon Apr 2, 2026
This is the same class of regression reported in #34365, introduced by PR #34300 which changed the
model_typecolumn fromString(40)toEnumText(ModelType). TheEnumText.process_result_value()inapi/models/types.pyuses the direct enum constructor instead of callingModelType.value_of(), so any legacy value that doesn't exactly match a current enum.valuewill crash [1].Immediate workaround — run these SQL updates against your database to normalize
reranking→rerank(and other known legacy values) across all affected tables:You may also want to normalize the other known legacy aliases at the same time [2]:
The proper long-term fix (as noted in #34365) would be for the codebase to either add a data migration or update
EnumText.process_result_value()to fall back tovalue_of()so legacy values are handled gracefully [3].To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
fix: Startup fails when legacy model_type "reranking" exists in DB: "…
hsiong commentedon Apr 12, 2026
I found that this issue was fixed in #34717, so I’m closing this. @laipz8200 @QuantumGhost