Repository navigation
fix(go-models): validate URL suffix config keys - #15734
Conversation
|
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 (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughProvider configuration loading adds strict validation for ChangesURL Suffix validation and config fixes
🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/entity/model_test.go (1)
184-186: ⚡ Quick winAssert config-file context in the failure message.
Line 184 currently validates only the unknown-field fragment. Add a second check for
unknown_suffix.jsonto lock in the wrapped file-context contract fromNewProviderManager.Proposed test hardening
if !strings.Contains(err.Error(), `unknown field "unknown_suffix"`) { t.Fatalf("error=%q, want unknown_suffix field", err) } + if !strings.Contains(err.Error(), "unknown_suffix.json") { + t.Fatalf("error=%q, want source config filename in error", err) + }🤖 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/model_test.go` around lines 184 - 186, The test currently only asserts the error contains the unknown-field fragment; update the assertion that checks err to also verify the wrapped config-file context string (unknown_suffix.json) is present so the NewProviderManager file-context contract is enforced; specifically, in the test where err is produced (the block that checks strings.Contains(err.Error(), `unknown field "unknown_suffix"`)), add a second check that strings.Contains(err.Error(), "unknown_suffix.json") and fail the test (t.Fatalf) if that context is missing.
🤖 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.
Nitpick comments:
In `@internal/entity/model_test.go`:
- Around line 184-186: The test currently only asserts the error contains the
unknown-field fragment; update the assertion that checks err to also verify the
wrapped config-file context string (unknown_suffix.json) is present so the
NewProviderManager file-context contract is enforced; specifically, in the test
where err is produced (the block that checks strings.Contains(err.Error(),
`unknown field "unknown_suffix"`)), add a second check that
strings.Contains(err.Error(), "unknown_suffix.json") and fail the test
(t.Fatalf) if that context is missing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c8c0f841-38e5-40f9-835a-9d1152cf39e9
📒 Files selected for processing (4)
conf/models/cohere.jsonconf/models/xai.jsoninternal/entity/model_test.gointernal/entity/models/types.go
1f463f8 to
fe17a76
Compare
fe17a76 to
a35a344
Compare
|
Thanks, good point. I removed the custom |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15734 +/- ##
=======================================
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:
|
Summary
Fixes typoed model-provider URL suffix keys and adds strict nested decoding so future URL suffix config mistakes fail during provider loading instead of being silently ignored.
What changed
url_suffix.embeddingstoembeddingso the embedding endpoint is loaded.url_suffix.asttoasrso the transcription endpoint is loaded.url_suffixdecoding in the provider config loader with unknown-field rejection.Why
The Go provider loader previously used normal JSON unmarshalling, so unknown
url_suffixkeys were dropped silently. That left affected endpoints empty at runtime while the config looked valid.Fixes #15591
Validation
go test ./internal/entitygo test ./internal/entity/models -run '^$'go vet ./internal/entityjq empty conf/models/*.jsongit diff --checkNotes
go test ./internal/entity/modelscurrently fails on pre-existing API-key validation expectations in unrelated model-driver tests; the package compiles with-run '^$', and the changed loader behavior is covered bygo test ./internal/entity.