Repository navigation
fix(mcp): Allow empty or scheme-less organizationUrl for self-hosted Sentry - #2361
sentry[bot] wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Looks good to me. I checked the premise against the producer in getsentry/sentry. The organization serializer sets links.organizationUrl from generate_organization_url(), and with no SENTRY_ORGANIZATION_URL_TEMPLATE (the self-hosted default) that returns the system.url-prefix option as-is. Nothing normalizes it, so whatever an admin typed, such as a host with no scheme, comes back. The linked issue matches: a stdio @sentry/mcp-server 0.49.0 user on a self-hosted host gets a 200 from GET /api/0/organizations/, and then 0.links.organizationUrl: Invalid URL. That means the value is a string but not a URL, so every org-scoped tool that lists orgs breaks for that install.
The fix is at the right boundary. The schema now accepts any string, and find_organizations maps anything that isn't an absolute URL to webUrl: null. That keeps its output schema (z.string().url().nullable()) honest, and we don't guess a scheme. regionUrl handling is unchanged apart from trimming, and find_organizations is the only consumer of organizationUrl in the repo. I merged the branch with current main and ran the checks there: mcp-core tsc and oxlint on the changed files are clean, and schema.test.ts and find-organizations.test.ts pass. The new schema cases fail against main's schema, so they really cover the bug.
| ) | ||
| .optional(), | ||
| organizationUrl: z.string().url(), | ||
| // Self-hosted Sentry returns `system.url-prefix` here, which may be |
There was a problem hiding this comment.
Pretty sure that is just a misconfigured Sentry installation, right? If that's so, we don't need to handle it here and attempt to solve a bunch of other edge cases.
Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
Problem
When listing organizations on a self-hosted Sentry instance,
listOrganizationsfails with anApiResponseValidationError: Unexpected API response: 0.links.organizationUrl: Invalid URL.Self-hosted Sentry instances construct
links.organizationUrlfrom theirsystem.url-prefixsetting when no organization URL template is configured. On instances wheresystem.url-prefixis unset, empty, or configured without a scheme, Sentry sends back an invalid URL string or an empty string, causingOrganizationSchemato reject the response.Changes
z.string().url()constraint onlinks.organizationUrlinpackages/mcp-core/src/api-client/schema.tsto keep strict schema validation per reviewer guidance, or document why misconfigured self-hosted installations are expected to configuresystem.url-prefixas a valid absolute URL.Fixes CLI-49Q
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry. You can adjust this setting at any time.