fix: ensure model_url is used from endpoint config#88
Conversation
WalkthroughDiscovery URL resolution in the HTTP client adapter now supports per-endpoint overrides via Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
internal/adapter/discovery/http_client.go (1)
141-148: Discovery URL override logic matches intent and preserves fallback behaviourUsing
endpoint.ModelURLStringwhen non-empty and falling back toplatformProfile.GetModelDiscoveryURL(endpoint.URLString)cleanly enables per-endpoint overrides while keeping existing behaviour untouched when no override is configured. The change is minimal, readable, and keeps error handling tied to the actual URL being called viaNetworkError{URL: discoveryURL, ...}, which is useful for debugging.The only thing to be mindful of is that
ModelURLStringshould always be initialised as a fully-qualified URL (not just a path) at construction time; from the tests and helpers this looks to be the case, so no change is strictly required here.internal/adapter/discovery/http_client_test.go (2)
625-727: Override tests correctly exercise per-endpoint ModelURLString behaviourThe table-driven
TestModelURLOverridedoes a good job of proving that discovery honours an endpoint-levelModelURLStringfor each profile: the test server only succeeds on the custom path, so any regression back to profile defaults would surface as a 404/error. TherequestedPathassertion is a nice guard to ensure the override path is actually used, not just “some” successful URL.The
profileDefaultPathfield in the test cases isn’t referenced in the body; it mainly serves as documentation of what the defaults are. You could either remove it or add a small assertion (e.g. thatrequestedPath != profileDefaultPath) if you want it to play an active role, but that’s purely cosmetic.
729-810: Fallback-to-profile-default tests solidify backwards-compatible semantics
TestModelURLFallbackToProfileDefaultclearly verifies that whenModelURLStringis empty, discovery routes via the profile’s default path for each profile type. The server-side 404-on-anything-else pattern ensures you’d immediately see a regression in the default URL mapping, and therequestedPathassertion makes the behaviour explicit.This nicely protects the original behaviour while allowing the new override semantics to coexist.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
internal/adapter/discovery/http_client.go(1 hunks)internal/adapter/discovery/http_client_test.go(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/adapter/discovery/http_client_test.go (3)
internal/core/domain/profile.go (5)
ProfileOllama(4-4)ProfileVLLM(9-9)ProfileLlamaCpp(6-6)ProfileLmStudio(7-7)ProfileOpenAICompatible(10-10)internal/adapter/discovery/http_client.go (1)
NewHTTPModelDiscoveryClientWithDefaults(54-71)internal/core/domain/endpoint.go (2)
Endpoint(19-40)StatusHealthy(53-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Cross-Platform Build Validation (windows-latest)
🔇 Additional comments (1)
internal/adapter/discovery/http_client_test.go (1)
817-840: Test helpers correctly distinguish default vs override discovery URL semanticsUpdating
createTestEndpointto initialiseModelUrlwhile leavingModelURLStringempty makes the default test endpoints behave like production ones that rely purely on profile-derived discovery URLs. The separatecreateTestEndpointWithModelURLhelper then cleanly models the override case by setting bothModelUrlandModelURLStringonly when an explicit override is provided.This separation keeps the tests clear about when they’re exercising default behaviour vs override behaviour and aligns well with the new logic in
discoverWithProfile.Also applies to: 842-867
This may address #86 and where specifying
model_urlhad no effect for llamacpp's profile.Now if
model_urlis specified in the endpoint config, it will use that and fall back only if it's not specified.Summary by CodeRabbit
Release Notes
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.