fix(bailian): preserve passthrough bodies#393
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughRenames the Alibaba Cloud provider from "Bailian" to "Alibaba Cloud Model Studio (Bailian)" across README, docs overview table, and the dedicated provider page. In ChangesProvider rename and passthrough hardening
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 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. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Greptile SummaryThis PR updates Bailian passthrough handling and provider documentation. It changes:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(bailian): guard passthrough request ..." | Re-trigger Greptile |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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 `@internal/providers/bailian/bailian.go`:
- Around line 111-116: Add a regression test in the bailian_test.go file that
verifies the error handling path when adaptPassthroughBody fails due to a read
error. Create a test function that instantiates a custom io.ReadCloser that
returns an error on read operations, construct a request with this
error-producing body, call the Passthrough function with this request, and
assert that the function returns the expected error rather than silently
forwarding. This test should specifically validate that unreadable passthrough
bodies are properly rejected and errors are propagated to the caller.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 3ee50cec-c1a2-4cdd-ab14-b1b75817165b
📒 Files selected for processing (6)
README.mddocs/docs.jsondocs/providers/bailian.mdxdocs/providers/overview.mdxinternal/providers/bailian/bailian.gointernal/providers/bailian/bailian_test.go
| adapted, err := adaptPassthroughBody(req.Body) | ||
| if err != nil { | ||
| slog.Warn("bailian: passthrough body adaptation failed, forwarding original body", | ||
| slog.Warn("bailian: passthrough body adaptation failed", | ||
| "error", err) | ||
| // Read the original body back so we can still forward it | ||
| req.Body, err = rewindBody(req.Body, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return p.compatible.Passthrough(ctx, req) | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Add a regression test for passthrough adaptation read failures.
This branch now fails fast on adaptation errors, but there isn’t a focused test proving that an unreadable passthrough body returns an error (instead of forwarding). Add a test with a custom io.ReadCloser that returns a read error, and assert Passthrough returns that error.
As per coding guidelines, "**/*_test.go: Add or update tests for behavior changes in Go code, covering ... error handling ... and provider-specific parameter mapping."
🤖 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 `@internal/providers/bailian/bailian.go` around lines 111 - 116, Add a
regression test in the bailian_test.go file that verifies the error handling
path when adaptPassthroughBody fails due to a read error. Create a test function
that instantiates a custom io.ReadCloser that returns an error on read
operations, construct a request with this error-producing body, call the
Passthrough function with this request, and assert that the function returns the
expected error rather than silently forwarding. This test should specifically
validate that unreadable passthrough bodies are properly rejected and errors are
propagated to the caller.
Source: Coding guidelines
Summary
Tests
Summary by CodeRabbit
Documentation
Bug Fixes
Tests