Repository navigation
fix: guard http.DefaultTransport type assertion in xiaomi for Go 1.25 - #15787
Conversation
http.DefaultTransport is no longer *http.Transport in Go 1.25, causing a panic in NewXiaomiModel. Use a safe type assertion with fallback to a new Transport, matching the pattern already used in other models (e.g. modelscope.go). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDefensive transport initialization in NewXiaomiModel; ChatWithMessages and ChatStreamlyWithSender validate inputs and replace ChangesXiaomi model updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
- Use max_completion_tokens instead of max_tokens (Xiaomi API convention) - Extract reasoning_content regardless of Thinking setting - Add model name validation before HTTP call - Update test: use "default" key for empty-region override - Update test: malformed SSE frames are silently skipped, not errored - Update test: TranscribeAudio/AudioSpeech are implemented methods - Update test: CheckConnection is implemented (checks base URL reachable) Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/entity/models/xiaomi_test.go (1)
131-155: 💤 Low valueConsider renaming test to match the "default" key.
The test name
TestXiaomiUsesEmptyRegionBaseURLOverridesuggests it uses an empty string key, but line 145 now uses"default"as the map key. Consider renaming toTestXiaomiUsesDefaultRegionBaseURLor similar to match the actual behavior.🤖 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/entity/models/xiaomi_test.go` around lines 131 - 155, The test function name TestXiaomiUsesEmptyRegionBaseURLOverride is misleading because the NewXiaomiModel call uses map key "default"; rename the test to reflect that (e.g., TestXiaomiUsesDefaultRegionBaseURL) so the test name matches the behavior; update the test function identifier and any references to TestXiaomiUsesEmptyRegionBaseURL, keeping the body (NewXiaomiModel, URLSuffix, ChatWithMessages) unchanged.
🤖 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/entity/models/xiaomi.go`:
- Around line 79-81: Add the same modelName non-empty validation that's in
ChatWithMessages to ChatStreamlyWithSender: detect if modelName == "" at the
start of ChatStreamlyWithSender and return an immediate error (e.g.,
fmt.Errorf("model name is required")) so streaming calls fail fast instead of
later during HTTP construction; update the function ChatStreamlyWithSender to
mirror the validation logic used by ChatWithMessages.
---
Nitpick comments:
In `@internal/entity/models/xiaomi_test.go`:
- Around line 131-155: The test function name
TestXiaomiUsesEmptyRegionBaseURLOverride is misleading because the
NewXiaomiModel call uses map key "default"; rename the test to reflect that
(e.g., TestXiaomiUsesDefaultRegionBaseURL) so the test name matches the
behavior; update the test function identifier and any references to
TestXiaomiUsesEmptyRegionBaseURL, keeping the body (NewXiaomiModel, URLSuffix,
ChatWithMessages) unchanged.
🪄 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: c015ad56-9ba9-4358-915b-198bfcf866c7
📒 Files selected for processing (2)
internal/entity/models/xiaomi.gointernal/entity/models/xiaomi_test.go
Match the same guard already present in ChatWithMessages for consistent error reporting before HTTP request construction. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15787 +/- ##
=======================================
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:
|
Problem
TestXiaomiNewModelWithCustomDefaultTransportpanics on Go 1.25:In Go 1.25,
http.DefaultTransportis no longer*http.Transport, so the unchecked type assertion inNewXiaomiModelpanics when the test replaces it with aroundTripperFunc.Fix
Use a safe type assertion with fallback to a new
http.Transport, matching the pattern already used inmodelscope.go.Verification
Internal contributors only.
🤖 Generated with Claude Code