Skip to content

Fix: model provider - #15634

Merged
wangq8 merged 12 commits into
infiniflow:mainfrom
Lynn-Inf:fix/model-provider-001
Jun 4, 2026
Merged

wangq8 merged 12 commits into
infiniflow:mainfrom
Lynn-Inf:fix/model-provider-001

Conversation

@Lynn-Inf

@Lynn-Inf Lynn-Inf commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Not display success when check not passed.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jun 4, 2026
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR corrects a bug in the verify_api_key function within provider_api_service.py. Previously, the function could return "success" even when model checks failed, provided the error message was empty. The fix explicitly computes a success boolean from embedding/chat/rerank checks and returns either the literal "success" string on success or the accumulated failure message directly on failure.

Changes

API Key Verification Return Logic

Layer / File(s) Summary
API Key Verification Return Logic
api/apps/services/provider_api_service.py
verify_api_key return statement now stores the result of model type checks in a success boolean and returns "success" conditionally, or the accumulated error message msg on failure, fixing the previous fallback behavior that used msg or "success".

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly Related PRs

  • infiniflow/ragflow#15517: Both PRs modify verify_api_key logic in provider_api_service.py; main PR refines its return behavior while retrieved PR adjusts the provider selection and verification flow leading to those checks.
  • infiniflow/ragflow#15460: The main PR fixes verify_api_key return-success/failure behavior, directly relating to the retrieved PR that first introduces verify_api_key for provider API key verification during instance creation.
  • infiniflow/ragflow#15588: Both PRs modify verify_api_key in the same file; main PR corrects final return behavior while retrieved PR adjusts the model selection flow within the function.

Suggested Labels

🐞 bug, size:M

Poem

🐰 A humble hop through logic clear,
Where "success" returns crisp and sincere,
No empty lies when checks do fail,
The message shines—the truthful tale,
One small fix, one greater whole!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix: model provider' is vague and does not clearly convey the specific bug being fixed; it lacks detail about the actual problem (incorrect success message handling in API key verification). Consider a more descriptive title such as 'Fix: prevent success message when API key verification fails' to better communicate the specific issue being addressed.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The PR description follows the template with both required sections present: 'What problem does this PR solve?' is answered and 'Type of change' is marked correctly as a Bug Fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@Lynn-Inf Lynn-Inf added the ci Continue Integration label Jun 4, 2026
@Lynn-Inf
Lynn-Inf marked this pull request as draft June 4, 2026 06:15
@Lynn-Inf
Lynn-Inf marked this pull request as ready for review June 4, 2026 06:15

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/apps/services/provider_api_service.py`:
- Around line 420-421: The return currently does `success = any([embd_passed,
chat_passed, rerank_passed])` and `return success, "success" if success else
msg`, which can return an empty string on failure; change the failure branch to
provide a non-empty default message (e.g., `msg or "no checks passed"` or a
concatenation/aggregate of individual check messages) so the function always
returns a meaningful error string when `success` is False; update the return
expression where `success`, `embd_passed`, `chat_passed`, `rerank_passed`, and
`msg` are used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4e0b8e3d-9b21-4e38-bab9-48f7d9d3b785

📥 Commits

Reviewing files that changed from the base of the PR and between 5db1b29 and 9110bda.

📒 Files selected for processing (1)
  • api/apps/services/provider_api_service.py

Comment on lines +420 to +421
success = any([embd_passed, chat_passed, rerank_passed])
return success, "success" if success else msg

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid returning an empty failure message on Line 421.

This fix correctly prevents false "success", but failure can still return "" when no check path populates msg, which produces blank API error responses downstream.

Proposed patch
-    success = any([embd_passed, chat_passed, rerank_passed])
-    return success, "success" if success else msg
+    success = any([embd_passed, chat_passed, rerank_passed])
+    if success:
+        return True, "success"
+    return False, msg or "API key verification failed"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
success = any([embd_passed, chat_passed, rerank_passed])
return success, "success" if success else msg
success = any([embd_passed, chat_passed, rerank_passed])
if success:
return True, "success"
return False, msg or "API key verification failed"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/apps/services/provider_api_service.py` around lines 420 - 421, The return
currently does `success = any([embd_passed, chat_passed, rerank_passed])` and
`return success, "success" if success else msg`, which can return an empty
string on failure; change the failure branch to provide a non-empty default
message (e.g., `msg or "no checks passed"` or a concatenation/aggregate of
individual check messages) so the function always returns a meaningful error
string when `success` is False; update the return expression where `success`,
`embd_passed`, `chat_passed`, `rerank_passed`, and `msg` are used.

@codecov

codecov Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15634   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 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.

@wangq8
wangq8 merged commit b65b18b into infiniflow:main Jun 4, 2026
1 of 2 checks passed
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:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants