Skip to content

fix(bailian): preserve passthrough bodies#393

Merged
SantiagoDePolonia merged 2 commits into
mainfrom
fix/bailian-passthrough-docs
Jun 14, 2026
Merged

fix(bailian): preserve passthrough bodies#393
SantiagoDePolonia merged 2 commits into
mainfrom
fix/bailian-passthrough-docs

Conversation

@SantiagoDePolonia

@SantiagoDePolonia SantiagoDePolonia commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve Bailian passthrough request bodies when no max_tokens rewrite is needed
  • Remove the now-unused rewind helper
  • Update provider docs to lead with Alibaba Cloud Model Studio while keeping bailian compatibility names documented

Tests

  • go test -v ./internal/providers/bailian
  • go test ./cmd/... ./internal/... ./config/...
  • python3 -m json.tool docs/docs.json
  • git diff --check
  • pre-commit hook: make test-race, make lint, mint validate, hot-path performance guard

Summary by CodeRabbit

  • Documentation

    • Updated Alibaba Cloud provider branding and terminology to “Model Studio (Bailian)” across provider guides and overview tables
    • Refreshed the Bailian compatibility notes and updated provider references
  • Bug Fixes

    • Improved Bailian passthrough handling to validate requests, properly surface body read/adaptation errors, and avoid silent fallback
  • Tests

    • Added coverage for nil requests and request-body read failures

@mintlify

mintlify Bot commented Jun 14, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
gomodel 🟢 Ready View Preview Jun 14, 2026, 11:54 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e1903f6e-1c2d-486d-b949-8891511f176c

📥 Commits

Reviewing files that changed from the base of the PR and between 2f2bc82 and aea2ccd.

📒 Files selected for processing (2)
  • internal/providers/bailian/bailian.go
  • internal/providers/bailian/bailian_test.go

📝 Walkthrough

Walkthrough

Renames the Alibaba Cloud provider from "Bailian" to "Alibaba Cloud Model Studio (Bailian)" across README, docs overview table, and the dedicated provider page. In bailian.go, the Passthrough function now returns errors from adaptPassthroughBody directly instead of falling back to the original body, validates that requests are non-nil, and adaptPassthroughBody returns a real io.ReadCloser when max_tokens is absent. The rewindBody helper is removed. Tests add error-handling coverage.

Changes

Provider rename and passthrough hardening

Layer / File(s) Summary
Provider rename across docs and README
README.md, docs/providers/overview.mdx, docs/docs.json, docs/providers/bailian.mdx
README and overview table row label updated to "Alibaba Cloud Model Studio (Bailian)". bailian.mdx retitles all headings, adds a compatibility note for legacy bailian/BAILIAN_* identifiers, and adds an English Model Studio reference link. docs.json nav entry repositioned.
Passthrough error handling refactor and tests
internal/providers/bailian/bailian.go, internal/providers/bailian/bailian_test.go
Passthrough now validates non-nil request and returns the adaptation error instead of rewinding and forwarding the original body. adaptPassthroughBody returns an io.ReadCloser over the original bytes when max_tokens is absent (previously returned nil). rewindBody helper deleted. Tests add TestPassthrough_NilRequest and TestPassthrough_ReadError coverage with errReadCloser helper; formatting updates applied to existing test struct literals.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • ENTERPILOT/GoModel#392: Introduced the initial Passthrough/adaptPassthroughBody implementation for the Bailian provider including the rewindBody fallback that this PR removes.

Poem

🐇 A bunny hops through the docs today,
Swapping "Bailian" for "Model Studio" — hooray!
The passthrough now fails with a proper loud shout,
No rewinding bodies — just error and out.
The rewindBody helper has taken its leave,
Clean code and good names, what a fine afternoon eve! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(bailian): preserve passthrough bodies' directly describes the main code change—fixing passthrough body preservation in the Bailian provider—which is the core objective of the PR.
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.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bailian-passthrough-docs

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.

@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates Bailian passthrough handling and provider documentation. It changes:

  • Preserves passthrough request bodies when no max_tokens rewrite is needed.
  • Returns an invalid-request error for nil Bailian passthrough requests.
  • Surfaces passthrough body read errors instead of forwarding an unreadable body.
  • Updates Alibaba Cloud provider docs to use Model Studio branding while keeping Bailian compatibility names.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
internal/providers/bailian/bailian.go Adds the nil passthrough guard before body adaptation and preserves passthrough body forwarding behavior.
internal/providers/bailian/bailian_test.go Adds coverage for nil passthrough requests and request-body read failures.

Reviews (2): Last reviewed commit: "fix(bailian): guard passthrough request ..." | Re-trigger Greptile

Comment thread internal/providers/bailian/bailian.go
@codecov-commenter

codecov-commenter commented Jun 14, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@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 `@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

📥 Commits

Reviewing files that changed from the base of the PR and between 48fee93 and 2f2bc82.

📒 Files selected for processing (6)
  • README.md
  • docs/docs.json
  • docs/providers/bailian.mdx
  • docs/providers/overview.mdx
  • internal/providers/bailian/bailian.go
  • internal/providers/bailian/bailian_test.go

Comment on lines 111 to 116
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
}

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.

🛠️ 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

@SantiagoDePolonia SantiagoDePolonia merged commit 70e5301 into main Jun 14, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants