fix: test model #1993 - #1995
Conversation
WalkthroughResolves testModel earlier in testChannel by trimming and defaulting before requestPath usage. The fallback order is: provided testModel → channel.TestModel → first from channel.GetModels() → "gpt-4o-mini". Removes later duplicate fallback logic. No other logic or signatures changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant T as testChannel
participant C as channel
participant RP as requestPath
Note over T: Input testModel (may be blank/whitespace)
T->>T: trim(testModel)
alt testModel empty
T->>C: read channel.TestModel
T->>T: trim(channel.TestModel)
alt still empty
T->>C: GetModels()
alt models available
T->>T: pick first model
else no models
T->>T: default "gpt-4o-mini"
end
end
end
Note over T,RP: testModel resolved before path selection
T->>RP: build requestPath using resolved testModel
RP-->>T: path ready
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 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 |
| testModel = strings.TrimSpace(testModel) | ||
| if testModel == "" { | ||
| if channel.TestModel != nil && *channel.TestModel != "" { | ||
| testModel = strings.TrimSpace(*channel.TestModel) | ||
| } else { | ||
| models := channel.GetModels() | ||
| if len(models) > 0 { | ||
| testModel = strings.TrimSpace(models[0]) | ||
| } | ||
| if testModel == "" { | ||
| testModel = "gpt-4o-mini" | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Handle whitespace-only channel.TestModel values.
If channel.TestModel contains only whitespace (e.g., " "), line 64's check passes (*channel.TestModel != ""), line 65 trims it to an empty string, but the fallback logic in lines 67-72 is skipped. This leaves testModel empty, which could cause request failures downstream.
Apply this diff to ensure fallbacks are checked after trimming:
testModel = strings.TrimSpace(testModel)
if testModel == "" {
- if channel.TestModel != nil && *channel.TestModel != "" {
+ if channel.TestModel != nil {
testModel = strings.TrimSpace(*channel.TestModel)
+ }
+ if testModel == "" {
+ models := channel.GetModels()
+ if len(models) > 0 {
+ testModel = strings.TrimSpace(models[0])
+ }
+ }
+ if testModel == "" {
+ testModel = "gpt-4o-mini"
- } else {
- models := channel.GetModels()
- if len(models) > 0 {
- testModel = strings.TrimSpace(models[0])
- }
- if testModel == "" {
- testModel = "gpt-4o-mini"
- }
}
}This flattens the conditional structure so each fallback is evaluated in sequence, ensuring empty results trigger the next fallback.
📝 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.
| testModel = strings.TrimSpace(testModel) | |
| if testModel == "" { | |
| if channel.TestModel != nil && *channel.TestModel != "" { | |
| testModel = strings.TrimSpace(*channel.TestModel) | |
| } else { | |
| models := channel.GetModels() | |
| if len(models) > 0 { | |
| testModel = strings.TrimSpace(models[0]) | |
| } | |
| if testModel == "" { | |
| testModel = "gpt-4o-mini" | |
| } | |
| } | |
| } | |
| testModel = strings.TrimSpace(testModel) | |
| if testModel == "" { | |
| if channel.TestModel != nil { | |
| testModel = strings.TrimSpace(*channel.TestModel) | |
| } | |
| if testModel == "" { | |
| models := channel.GetModels() | |
| if len(models) > 0 { | |
| testModel = strings.TrimSpace(models[0]) | |
| } | |
| } | |
| if testModel == "" { | |
| testModel = "gpt-4o-mini" | |
| } | |
| } | |
| } |
🤖 Prompt for AI Agents
In controller/channel-test.go around lines 62 to 75, the current nested
conditional treats a whitespace-only channel.TestModel as non-empty and skips
fallbacks; change the logic to first trim testModel and, if empty, check
channel.TestModel (trimmed) and if still empty evaluate channel.GetModels() (use
first trimmed model if present), and finally set the default "gpt-4o-mini" if
all previous results are empty; flatten the conditionals so each fallback is
evaluated in sequence after trimming.
Summary by CodeRabbit
Bug Fixes
Tests