Skip to content

fix: resolve embedding-model fallbacks from deployment env, never guess - #2191

Draft
edwinjosechittilappilly wants to merge 2 commits into
release-cpd-0.6.0from
fix/embedding-model-fallback-not-validated
Draft

fix: resolve embedding-model fallbacks from deployment env, never guess#2191
edwinjosechittilappilly wants to merge 2 commits into
release-cpd-0.6.0from
fix/embedding-model-fallback-not-validated

Conversation

@edwinjosechittilappilly

Copy link
Copy Markdown
Collaborator

Summary

  • _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).
  • Added 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.
  • Wired 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.

Note

This is a necessary but not sufficient fix for the specific incident that motivated it — the affected cluster's EMBEDDING_MODEL/EMBEDDING_PROVIDER env 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_model tests, confirmed present identically on unmodified release-cpd-0.6.0 before this change.
  • Verified diff is empty-conflict cherry-pick from a main-based version of the same fix onto release-cpd-0.6.0.

_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.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e18c30f-2b54-4013-80a0-93c0ba3a3fc0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests bug 🔴 Something isn't working. labels Jul 31, 2026
@github-actions github-actions Bot added bug 🔴 Something isn't working. and removed bug 🔴 Something isn't working. labels Jul 31, 2026
@edwinjosechittilappilly

Copy link
Copy Markdown
Collaborator Author

@coderabbitai mention the risk of merging the pr and does it need full regression testing of onboarding and ingestions?

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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)' || true

Length 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 all

Length 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 all

Length of output: 17908


@edwinjosechittilappilly: The merge risk is moderate.

This PR removes unsafe hardcoded model selection. That change prevents ingestion from selecting a model that the deployment gateway does not serve.

However, if EMBEDDING_MODEL and EMBEDDING_PROVIDER are unset, or do not match the active embedding provider, the new resolver returns an empty model. The affected deployment currently has both variables unset. Therefore, this PR alone will not restore ingestion on that deployment. The infrastructure change must set both variables to the valid deployed model and provider.

The changed runtime paths include:

  • Settings provider removal.
  • Langflow ingestion index creation.
  • Non-Langflow index creation.
  • Search embedding selection.

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:

  1. Set EMBEDDING_PROVIDER and EMBEDDING_MODEL to a valid matching deployment value.
  2. Run onboarding sample-document ingestion through Langflow.
  3. Run file ingestion through the Langflow path.
  4. Run non-Langflow ingestion if that mode is supported in the deployment.
  5. Verify search against the ingested documents.
  6. Verify provider removal falls back to the declared model when the environment variables match.
  7. Verify provider removal leaves the model empty when no declared default exists, and that the UI requires an explicit model selection.

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 ricofurtado left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - It is working for me.

@github-actions github-actions Bot added the lgtm label Jul 31, 2026
@edwinjosechittilappilly
edwinjosechittilappilly marked this pull request as draft July 31, 2026 18:43
edwinjosechittilappilly added a commit that referenced this pull request Jul 31, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) bug 🔴 Something isn't working. lgtm tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants