fix: resolve embedding-model fallbacks from deployment env, never guess - #2191
fix: resolve embedding-model fallbacks from deployment env, never guess#2191edwinjosechittilappilly wants to merge 2 commits into
Conversation
_default_embedding_model() previously hardcoded a per-provider guess (e.g. "text-embedding-3-small" for openai) used whenever a provider removal left another provider as the embedding fallback. A provider name doesn't reliably say which models are actually deployed — it's often an internal OpenAI/watsonx-compatible gateway with a curated model subset. The hardcoded guess silently selected a model the gateway didn't serve, breaking every ingestion with no clear signal why (incident: gateway only served "text-embedding-3-large"; 25/25 files failed at the Langflow embedding step). Add get_declared_default_embedding_model(), which resolves the deployment's own declared default from EMBEDDING_MODEL / EMBEDDING_PROVIDER (Helm values / operator ConfigMap) instead of a hardcoded string, and returns "" when the deployment hasn't declared one for that provider. Read directly rather than through ConfigManager's env-override path, which is skipped once config.edited is True — a protection meant for a user's own prior choices, not a reason to block resolving an unmade choice. Wire this into every "guess an embedding model" call site, not just the settings-save path: search_service.py, utils/embeddings.py, and langflow_file_service.py all previously fell back to the same hardcoded constant when no model was configured; they now fall back to the deployment-declared default (or none) instead.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai mention the risk of merging the pr and does it need full regression testing of onboarding and ingestions? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Pull request metadata =='
gh pr view 2191 --repo langflow-ai/openrag --json title,body,changedFiles,additions,deletions,files \
--jq '{title, changedFiles, additions, deletions, files: [.files[].path]}'
echo
echo '== Changed-file diff summary =='
gh pr diff 2191 --repo langflow-ai/openrag --name-only
echo
echo '== Relevant symbols and tests =='
rg -n -C 3 \
'get_declared_default_embedding_model|_default_embedding_model|EMBEDDING_MODEL|EMBEDDING_PROVIDER' \
. \
-g '*.py' \
-g '!**/.git/**' || true
echo
echo '== Candidate test files =='
fd -t f -e py . tests 2>/dev/null | rg \
'(settings_provider_removal_defaults|embedding_fields|skip_os_security_setup_init_index|embedding|ingestion|onboarding)' || trueLength of output: 31556 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Pull request diff =='
gh pr diff 2191 --repo langflow-ai/openrag -- \
src/config/embedding_constants.py \
src/api/settings/helpers.py \
src/services/langflow_file_service.py \
src/services/search_service.py \
src/utils/embeddings.py \
tests/unit/test_settings_provider_removal_defaults.py
echo
echo '== Changed-function outlines =='
ast-grep outline src/config/embedding_constants.py --items all
ast-grep outline src/services/langflow_file_service.py --items all --match 'detect|index|embedding'
ast-grep outline src/services/search_service.py --items all --match 'search|embedding'
ast-grep outline src/utils/embeddings.py --items all
echo
echo '== Relevant test outlines =='
ast-grep outline tests/integration/core/test_onboarding_sample_docs.py --items all
ast-grep outline tests/integration/core/test_non_langflow_ingestion.py --items all
ast-grep outline tests/unit/test_settings_provider_removal_defaults.py --items allLength of output: 1348 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Pull request diff =='
gh pr diff 2191 --repo langflow-ai/openrag
echo
echo '== Changed-function outlines =='
ast-grep outline src/config/embedding_constants.py --items all
ast-grep outline src/services/langflow_file_service.py --items all
ast-grep outline src/services/search_service.py --items all
ast-grep outline src/utils/embeddings.py --items all
echo
echo '== Relevant test outlines =='
ast-grep outline tests/integration/core/test_onboarding_sample_docs.py --items all
ast-grep outline tests/integration/core/test_non_langflow_ingestion.py --items all
ast-grep outline tests/unit/test_settings_provider_removal_defaults.py --items allLength of output: 17908
This PR removes unsafe hardcoded model selection. That change prevents ingestion from selecting a model that the deployment gateway does not serve. However, if The changed runtime paths include:
A full onboarding and ingestion regression suite is not required for this focused change. Targeted integration validation is required before merge or immediately after deployment:
The existing unit tests validate the settings fallback behavior. They do not directly validate the changed onboarding, ingestion, and search runtime paths. You are interacting with an AI system. |
ricofurtado
left a comment
There was a problem hiding this comment.
LGTM - It is working for me.
…ss (backport of #2191) (#2192) * fix: resolve embedding-model fallbacks from deployment env, never guess _default_embedding_model() previously hardcoded a per-provider guess (e.g. "text-embedding-3-small" for openai) used whenever a provider removal left another provider as the embedding fallback. A provider name doesn't reliably say which models are actually deployed — it's often an internal OpenAI/watsonx-compatible gateway with a curated model subset. The hardcoded guess silently selected a model the gateway didn't serve, breaking every ingestion with no clear signal why (incident: gateway only served "text-embedding-3-large"; 25/25 files failed at the Langflow embedding step). Add get_declared_default_embedding_model(), which resolves the deployment's own declared default from EMBEDDING_MODEL / EMBEDDING_PROVIDER (Helm values / operator ConfigMap) instead of a hardcoded string, and returns "" when the deployment hasn't declared one for that provider. Read directly rather than through ConfigManager's env-override path, which is skipped once config.edited is True — a protection meant for a user's own prior choices, not a reason to block resolving an unmade choice. Wire this into every "guess an embedding model" call site, not just the settings-save path: search_service.py, utils/embeddings.py, and langflow_file_service.py all previously fell back to the same hardcoded constant when no model was configured; they now fall back to the deployment-declared default (or none) instead. * style: ruff autofix (auto) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Summary
_default_embedding_model()previously hardcoded a per-provider guess (e.g.text-embedding-3-smallforopenai) used whenever a provider removal left another provider as the embedding fallback. A provider name doesn't reliably say which models are actually deployed — it's often an internal OpenAI/watsonx-compatible gateway with a curated model subset. The hardcoded guess silently selected a model the gateway didn't serve, breaking every ingestion with no clear signal why (incident: gateway only servedtext-embedding-3-large; 25/25 files failed at the Langflow embedding step).get_declared_default_embedding_model(), which resolves the deployment's own declared default fromEMBEDDING_MODEL/EMBEDDING_PROVIDER(Helm values / operator ConfigMap) instead of a hardcoded string, and returns""when the deployment hasn't declared one for that provider. Read directly rather than throughConfigManager's env-override path, which is skipped onceconfig.editedisTrue— a protection meant for a user's own prior choices, not a reason to block resolving an unmade choice.search_service.py,utils/embeddings.py, andlangflow_file_service.pyall previously fell back to the same hardcoded constant when no model was configured; they now fall back to the deployment-declared default (or none) instead.Note
This is a necessary but not sufficient fix for the specific incident that motivated it — the affected cluster's
EMBEDDING_MODEL/EMBEDDING_PROVIDERenv vars are currently unset, so it also needs an infra-side change (outside this repo) to actually populate them from a correct value.Test plan
uv run pytest tests/unit/test_settings_provider_removal_defaults.py tests/unit/test_embedding_fields.py tests/unit/test_skip_os_security_setup_init_index.py -q— 48 passed; 3 pre-existing failures in unrelated_default_llm_modeltests, confirmed present identically on unmodifiedrelease-cpd-0.6.0before this change.main-based version of the same fix ontorelease-cpd-0.6.0.