-
Notifications
You must be signed in to change notification settings - Fork 28
fix: gracefully handle missing regions endpoint on self-hosted Sentry #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixes MCP-SERVER-E9M by implementing graceful fallback when the /users/me/regions/ endpoint returns 404 on self-hosted Sentry instances. Changes: - Add isSaas() method to check if host is sentry.io - Update listOrganizations() to skip regions endpoint for self-hosted - Add fallback to direct organizations endpoint when regions fails - Update getIssueUrl() and getTraceUrl() to use isSaas() This ensures compatibility with older self-hosted Sentry versions that don't have the regions endpoint while maintaining full multi-region support for Sentry SaaS users. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
json: () => Promise.resolve(mockRegionsResponse), | ||
}); | ||
} | ||
if (url.includes("us.sentry.io")) { |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
us.sentry.io
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
To fix the issue, the code should parse the URL and validate its host explicitly instead of using a substring check. This ensures that the host is exactly what is expected and not part of a larger, malicious URL. The URL
class in JavaScript can be used to parse the URL and extract its host for comparison.
The changes will involve replacing the url.includes("us.sentry.io")
and similar checks with a comparison of the parsed host against the expected value ("us.sentry.io"
or "eu.sentry.io"
). This ensures that only URLs with the exact host are accepted.
-
Copy modified lines R233-R234 -
Copy modified line R240
@@ -232,3 +232,4 @@ | ||
} | ||
if (url.includes("us.sentry.io")) { | ||
const parsedUrl = new URL(url); | ||
if (parsedUrl.host === "us.sentry.io") { | ||
return Promise.resolve({ | ||
@@ -238,3 +239,3 @@ | ||
} | ||
if (url.includes("eu.sentry.io")) { | ||
if (parsedUrl.host === "eu.sentry.io") { | ||
return Promise.resolve({ |
json: () => Promise.resolve(mockOrgsUs), | ||
}); | ||
} | ||
if (url.includes("eu.sentry.io")) { |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High
eu.sentry.io
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
To fix the issue, replace the substring check (url.includes
) with a more robust method that parses the URL and explicitly checks the host. This ensures that only URLs with the exact expected host are matched. The URL
constructor in JavaScript can be used to parse the URL and extract its host
property for comparison.
The changes will be made in the mocked fetch
implementation, specifically in the conditions that check for us.sentry.io
and eu.sentry.io
.
-
Copy modified lines R233-R234 -
Copy modified line R240
@@ -232,3 +232,4 @@ | ||
} | ||
if (url.includes("us.sentry.io")) { | ||
const parsedUrl = new URL(url); | ||
if (parsedUrl.host === "us.sentry.io") { | ||
return Promise.resolve({ | ||
@@ -238,3 +239,3 @@ | ||
} | ||
if (url.includes("eu.sentry.io")) { | ||
if (parsedUrl.host === "eu.sentry.io") { | ||
return Promise.resolve({ |
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #367 +/- ##
==========================================
+ Coverage 60.10% 60.19% +0.08%
==========================================
Files 77 77
Lines 6715 6730 +15
Branches 532 539 +7
==========================================
+ Hits 4036 4051 +15
Misses 2679 2679
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes MCP-SERVER-E9M by implementing graceful fallback when the /users/me/regions/ endpoint returns 404 on self-hosted Sentry instances.
Changes:
This ensures compatibility with older self-hosted Sentry versions that don't have the regions endpoint while maintaining full multi-region support for Sentry SaaS users.
🤖 Generated with Claude Code