fix(coderd): accept RFC 9728 resource metadata with array-valued resource - #28592
Conversation
…urce GitLab's official MCP server returns "resource" as a JSON array in its /.well-known/oauth-protected-resource document, while RFC 9728 defines it as a string. Coder's OAuth2 auto-discovery failed to decode the array, blocking zero-config oauth2 DCR against GitLab. Tolerate both a single string and an array of strings. Part of CODAGT-570. The other half of that issue (204 responses to notifications) was already fixed by the migration to modelcontextprotocol/go-sdk.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Cherry-pick PR created: #28647 |
Live verification against GitLab CE 19.0.1Ran this branch against the exact setup from CODAGT-570: Both quirks reproduced with curl:
Gap 1 (204 handshake), fixed by the earlier Gap 2 (resource array), fixed by this PR: the real Negative control: same test with Together with the SDK migration, this PR fully resolves CODAGT-570. Generated by Coder Agents on behalf of @f0ssel. |
GitLab's official MCP server returns
"resource"as a JSON array in its/.well-known/oauth-protected-resourcedocument, while RFC 9728 §2 defines it as a string. Coder's OAuth2 auto-discovery failed to decode the response (json: cannot unmarshal array into Go struct field protectedResourceMetadata.resource of type string), blocking zero-configoauth2DCR against GitLab.This makes
protectedResourceMetadata.Resourcetolerate both a single string and an array of strings.Part of CODAGT-570. The other blocker in that issue (GitLab replying 204 to
notifications/initialized) was already fixed by the migration frommark3labs/mcp-gotomodelcontextprotocol/go-sdk, whose streamable-HTTP client accepts 204.Investigation notes
CODAGT-570 reported two independent incompatibilities with GitLab CE's
/api/v4/mcpserver:notifications/initialized(blocked all auth modes): the bundledmark3labs/mcp-goclient only accepted 200/202 for notification POSTs. That library has since been removed entirely;coderd/x/chatd/mcpclientnow usesgithub.com/modelcontextprotocol/go-sdk v1.7.0, which accepts both 204 and 202 (and only warns on other codes in non-strict mode, which is the only mode reachable from Coder). No further change needed.resourcearray (blocked zero-config oauth2 DCR): Coder's own parser incoderd/mcp.godeclaredResource string. This lives outside the MCP library, so the SDK migration did not fix it. Fixed here with a customUnmarshalJSONaccepting string or array of strings. The field is only decoded, never consumed downstream, so behavior is otherwise unchanged.Generated by Coder Agents on behalf of @f0ssel.