Skip to content

Fix: model_type not passed in ensure_tenant_model_id_for_params causing wrong tenant model lookup - #13782

Merged
yingfeng merged 1 commit into
infiniflow:mainfrom
SyedShahmeerAli12:fix/ensure-tenant-model-type-filter
Apr 13, 2026
Merged

yingfeng merged 1 commit into
infiniflow:mainfrom
SyedShahmeerAli12:fix/ensure-tenant-model-type-filter

Conversation

@SyedShahmeerAli12

Copy link
Copy Markdown
Contributor

Summary

When setting a default model for an OpenAI-API-Compatible provider, ensure_tenant_model_id_for_params called get_api_key
without a model_type filter. If the same model name was registered under multiple types (e.g., both chat and embedding),
it could return the wrong tenant_llm_id, leading to Model(@None) not authorized errors during chat.

This applies the same type-scoped fix that PR #13569 introduced in get_model_config_by_type_and_name — now consistently
in tenant_utils.py as well.

Changes

  • Added _KEY_TO_MODEL_TYPE mapping in tenant_utils.py
  • Each model key (llm_id, embd_id, etc.) now passes its correct LLMType to get_api_key

Fixes #13775

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Mar 25, 2026
@yingfeng yingfeng added the ci Continue Integration label Mar 26, 2026
@yingfeng
yingfeng marked this pull request as draft March 26, 2026 13:15
@yingfeng
yingfeng marked this pull request as ready for review March 26, 2026 13:15
@codecov

codecov Bot commented Mar 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.52%. Comparing base (1b29522) to head (f937f68).
⚠️ Report is 143 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main   #13782       +/-   ##
===========================================
+ Coverage   49.52%   96.52%   +46.99%     
===========================================
  Files          45       10       -35     
  Lines        9657      690     -8967     
  Branches      112      108        -4     
===========================================
- Hits         4783      666     -4117     
+ Misses       4864        8     -4856     
- Partials       10       16        +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yingfeng
yingfeng requested a review from Magicbook1108 April 2, 2026 06:18

@Magicbook1108 Magicbook1108 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

GOOD

When the same model name exists for multiple types (common with
OpenAI-API-Compatible providers), calling get_api_key without a
model_type filter could return the wrong tenant_llm_id, causing the
tenant_{key} columns to reference an incorrect model type.

This is the same class of bug fixed in PR infiniflow#13569 for
get_model_config_by_type_and_name, now applied consistently to
ensure_tenant_model_id_for_params in tenant_utils.py.

Fixes infiniflow#13775
@SyedShahmeerAli12
SyedShahmeerAli12 force-pushed the fix/ensure-tenant-model-type-filter branch from 3bde268 to f937f68 Compare April 2, 2026 14:52
@yingfeng
yingfeng merged commit c7ce062 into infiniflow:main Apr 13, 2026
1 check passed
JasleenKaurSethi pushed a commit to stackhpc/ragflow that referenced this pull request Apr 28, 2026
…ing wrong tenant model lookup (infiniflow#13782)

Summary

When setting a default model for an OpenAI-API-Compatible provider,
ensure_tenant_model_id_for_params called get_api_key
without a model_type filter. If the same model name was registered under
multiple types (e.g., both chat and embedding),
it could return the wrong tenant_llm_id, leading to Model(@None) not
authorized errors during chat.

This applies the same type-scoped fix that PR infiniflow#13569 introduced in
get_model_config_by_type_and_name — now consistently
  in tenant_utils.py as well.

  Changes

  - Added _KEY_TO_MODEL_TYPE mapping in tenant_utils.py
- Each model key (llm_id, embd_id, etc.) now passes its correct LLMType
to get_api_key

  Fixes infiniflow#13775
tmimmanuel pushed a commit to tmimmanuel/ragflow that referenced this pull request May 14, 2026
…ing wrong tenant model lookup (infiniflow#13782)

Summary

When setting a default model for an OpenAI-API-Compatible provider,
ensure_tenant_model_id_for_params called get_api_key
without a model_type filter. If the same model name was registered under
multiple types (e.g., both chat and embedding),
it could return the wrong tenant_llm_id, leading to Model(@None) not
authorized errors during chat.

This applies the same type-scoped fix that PR infiniflow#13569 introduced in
get_model_config_by_type_and_name — now consistently
  in tenant_utils.py as well.

  Changes

  - Added _KEY_TO_MODEL_TYPE mapping in tenant_utils.py
- Each model key (llm_id, embd_id, etc.) now passes its correct LLMType
to get_api_key

  Fixes infiniflow#13775
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenAI-API-Compatible provider cannot be set as default model (Error 101: tenant_id missing)

3 participants