Repository navigation
Fix add VLLM without apikey will fail - #16352
Conversation
📝 WalkthroughWalkthroughProvider API endpoints now allow VLLM requests to omit ChangesVLLM API-key handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
api/apps/restful_apis/provider_api.py (1)
316-318: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winUpdate the request schema for VLLM’s optional api_key.
The OpenAPI body schemas still require
api_keyunconditionally, so generated clients/docs will continue blocking the new VLLM-without-key flow. Please align the schema with the conditional validation, preferably via Pydantic request models to avoid future drift. As per coding guidelines,api/apps/restful_apis/**/*.py: Use Pydantic request validation in RESTful APIs.Also applies to: 386-387
🤖 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/restful_apis/provider_api.py` around lines 316 - 318, The OpenAPI request schema still marks api_key as always required, which conflicts with the conditional VLLM flow. Update the request model/schema in provider_api so api_key is optional for VLLM and only enforced by the existing validation logic, ideally by switching the REST endpoint to a Pydantic request model to keep docs and validation aligned. Make sure the schema generation for the relevant provider request path reflects the conditional requirement rather than a blanket required field.Source: Coding guidelines
🧹 Nitpick comments (1)
api/apps/services/provider_api_service.py (1)
54-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLog the VLLM placeholder substitution.
This is a new flow and silently changes missing credentials to
"x". Add a debug log in the VLLM branch without logging any key material. As per coding guidelines,**/*.py: Add logging for new flows.Proposed logging addition
def _normalize_provider_api_key(provider_name: str, api_key: str | dict | None): if provider_name == "VLLM" and not api_key: + logging.debug("provider_api: using placeholder api_key for VLLM without configured key") return "x" return api_key🤖 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 54 - 58, The _normalize_provider_api_key helper silently substitutes a missing VLLM api_key with the placeholder value, so add a debug log in the provider_name == "VLLM" branch before returning the placeholder. Use the existing logging approach in this module and make sure the message only states that a placeholder is being used, without including any key material or the api_key value itself.Source: Coding guidelines
🤖 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/restful_apis/provider_api.py`:
- Around line 339-343: The missing api_key check in the provider creation/update
flow is using the raw provider_id_or_name value, so the VLLM exemption only
works for the literal string "VLLM" and can reject valid VLLM provider IDs
before normalization. Update the validation in the provider_api entry points
around the current instance_name/api_key handling and the provider_api_service
call so the provider is resolved first, or move the missing-key enforcement into
the service layer after provider lookup, and keep the exemption tied to the
resolved provider name rather than the input path value.
---
Outside diff comments:
In `@api/apps/restful_apis/provider_api.py`:
- Around line 316-318: The OpenAPI request schema still marks api_key as always
required, which conflicts with the conditional VLLM flow. Update the request
model/schema in provider_api so api_key is optional for VLLM and only enforced
by the existing validation logic, ideally by switching the REST endpoint to a
Pydantic request model to keep docs and validation aligned. Make sure the schema
generation for the relevant provider request path reflects the conditional
requirement rather than a blanket required field.
---
Nitpick comments:
In `@api/apps/services/provider_api_service.py`:
- Around line 54-58: The _normalize_provider_api_key helper silently substitutes
a missing VLLM api_key with the placeholder value, so add a debug log in the
provider_name == "VLLM" branch before returning the placeholder. Use the
existing logging approach in this module and make sure the message only states
that a placeholder is being used, without including any key material or the
api_key value itself.
🪄 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: 3c7b0fc1-897d-4742-b102-06b6381cccfc
📒 Files selected for processing (2)
api/apps/restful_apis/provider_api.pyapi/apps/services/provider_api_service.py
| if not data or "instance_name" not in data or ("api_key" not in data and provider_id_or_name != "VLLM"): | ||
| return get_error_argument_result(message="instance_name and api_key are required") | ||
|
|
||
| instance_name = data["instance_name"] | ||
| api_key = data["api_key"] | ||
| api_key = data.get("api_key", "") |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Resolve the provider before applying the VLLM api_key exemption.
Line 339 and Line 408 only exempt the literal path value "VLLM", but this route accepts a provider ID or name. A VLLM provider ID without api_key will still be rejected before provider_api_service can normalize it. Resolve the provider name first, or defer missing-key validation to the service layer.
Also applies to: 408-412
🤖 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/restful_apis/provider_api.py` around lines 339 - 343, The missing
api_key check in the provider creation/update flow is using the raw
provider_id_or_name value, so the VLLM exemption only works for the literal
string "VLLM" and can reject valid VLLM provider IDs before normalization.
Update the validation in the provider_api entry points around the current
instance_name/api_key handling and the provider_api_service call so the provider
is resolved first, or move the missing-key enforcement into the service layer
after provider lookup, and keep the exemption tied to the resolved provider name
rather than the input path value.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16352 +/- ##
=======================================
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. 🚀 New features to boost your workflow:
|
No description provided.