Skip to content

Conversation

@souredoutlook
Copy link
Contributor

@souredoutlook souredoutlook commented Jan 27, 2026

this PR adds some truncation logic for long URLs which were previously omitted entirely

here's the resulting url tag after truncation: "https://example.com/api/v1/very-long-path-segment-with-many-characters/very-long-path-segment-with-many-characters/very-long-path-segment-with-many-characters/very-long-path-segment-with-many-chara..."

When generated from this script:

const Sentry = require('@sentry/node');

// Generate a 400 character URL (characters in the path, not query string)
const baseUrl = 'https://example.com/api/v1/';
const pathSegment = 'very-long-path-segment-with-many-characters/';
// Calculate how many segments we need to reach 400 characters
const targetLength = 400;
const currentLength = baseUrl.length;
const segmentLength = pathSegment.length;
const segmentsNeeded = Math.ceil((targetLength - currentLength) / segmentLength);
const longPath = pathSegment.repeat(segmentsNeeded);
const longUrl = baseUrl + longPath.slice(0, targetLength - currentLength) + 'endpoint';

// Initialize Sentry with the provided DSN
Sentry.init({
  dsn: 'http://some-dsn@dev.getsentry.net:8000/1',
  // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring
  tracesSampleRate: 1.0,
  // Modify events before they are sent to add request interface
  beforeSend(event) {
    // Add request interface with a 400 character URL
    event.request = {
      url: longUrl,
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
      },
      query_string: longUrl.split('?')[1] || '',
    };

    console.log(`Request URL length: ${event.request.url.length} characters`);
    return event;
  },
});

// Send a test error to Sentry
try {
  throw new Error('This is a test error sent to Sentry!');
} catch (error) {
  Sentry.captureException(error);
  console.log('Error sent to Sentry successfully!');
}

// Give Sentry time to send the event before the script exits
setTimeout(() => {
  console.log('Script completed.');
  process.exit(0);
}, 2000);

As part of response to this feedback here: https://x.com/tim_nolet/status/2008955053646991863


Note

Adds length guard for URL tags extracted from request interface.

  • UrlsPlugin.get_tag_values now truncates request.url to MAX_TAG_VALUE_LENGTH, appending ... when exceeded
  • New tests cover short URLs, truncation behavior (including exact length), and cases with missing/empty request URL

Written by Cursor Bugbot for commit 2ea2f37. This will update automatically on new commits. Configure here.

@souredoutlook souredoutlook requested a review from Dav1dde January 27, 2026 17:12
@souredoutlook souredoutlook requested a review from a team as a code owner January 27, 2026 17:12
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

3 participants