fix(api,cli): stop auto-deriving RFC 8707 resource indicator from URL#5204
fix(api,cli): stop auto-deriving RFC 8707 resource indicator from URL#5204
Conversation
The API path unconditionally derived the RFC 8707 resource parameter from the server URL, while the CLI only did so when --resource-url was explicitly passed. This broke OAuth for servers like Common Room that don't support RFC 8707. Remove the automatic URL-to-resource fallback in both buildRemoteAuthConfigFromMetadata and createRequestToRemoteAuthConfig, keeping only user-provided and metadata-provided resource values. Fixes: #5203 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Config Verify that resource is NOT auto-derived from URL when not explicitly set, and that an explicitly provided resource is preserved verbatim. These tests guard against re-introducing the removed fallback derivation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Also fix the CLI registry path (getRemoteAuthFromRemoteServerMetadata) which had the same unconditional fallback to DefaultResourceIndicator. Inline orphaned variable in createRequestToRemoteAuthConfig. The resource parameter is now only set when explicitly provided by the user or registry metadata, matching the behavior of the direct CLI path which gates on --resource-url. Refs: #5203 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Removes implicit RFC 8707 resource parameter derivation from remote server URLs in the API and CLI registry-based OAuth config builders, so resource is only set when explicitly provided (by user input or registry metadata), preventing OAuth failures on providers that reject unknown resource values.
Changes:
- Removed unconditional
resourcefallback derivation (remote.DefaultResourceIndicator(url)) in API registry/direct config builders. - Removed unconditional
resourcederivation in CLI “from registry metadata” config builder. - Updated/added tests to ensure
resourceremains empty unless explicitly provided.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/api/v1/workloads_types_test.go | Adds regression subtests ensuring API direct path does not auto-derive resource. |
| pkg/api/v1/workload_service.go | Removes resource auto-derivation in API registry/direct remote auth config builders. |
| pkg/api/v1/workload_service_test.go | Updates expectations to assert resource remains empty when unset. |
| cmd/thv/app/run_flags.go | Removes unconditional resource derivation in CLI registry-metadata path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5204 +/- ##
==========================================
- Coverage 67.72% 67.67% -0.05%
==========================================
Files 607 607
Lines 61984 61979 -5
==========================================
- Hits 41978 41947 -31
- Misses 16845 16872 +27
+ Partials 3161 3160 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@claude succinct review |
|
Claude finished @peppescg's task in 1m 9s —— View job ReviewLGTM with one minor note. The fix is correct and tightly scoped. Removing the three The Copilot comment on Minor nit: the test comment in Everything else — the |
Add explanatory comment on registry path resource assignment explaining why --resource-url derivation is intentionally skipped. Reword test comment to be reader-facing rather than author-local. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
resourceparameter from the server URL in the API and CLI registry pathsresourceparameter is now only set when explicitly provided by the user or registry metadataresourcewhen--resource-urlis explicitly passedFixes #5203
Root cause
Three code paths built
remote.Configfor OAuth:resource?buildRemoteAuthConfigFromMetadatacreateRequestToRemoteAuthConfiggetRemoteAuthFromRemoteServerMetadatagetRemoteAuthFromRunFlags--resource-urlsetThe first three always fell back to
DefaultResourceIndicator(url), sendingresource=<server-url>in the OAuth authorize URL. Servers that don't support RFC 8707 (e.g., Common Room) reject this with "Service not found".After this fix, all paths behave consistently:
resourceis only set from explicit user input or registry metadata. Servers that support RFC 9728 will still work via runtime discovery (.well-known/oauth-protected-resource).Test plan
TestBuildRemoteAuthConfigFromMetadatatests updated and passcreateRequestToRemoteAuthConfigverify resource is not auto-derivedgo test ./pkg/api/v1/...passesgo build ./cmd/thv/...passesTested vs ToolHive Studio
Kapture.2026-05-06.at.15.14.09.mp4
🤖 Generated with Claude Code