getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
37.55k stars 4.04k forks source link

Issues with different status codes get incorrectly grouped into a single issue #71630

Open Dhrumil-Sentry opened 1 month ago

Dhrumil-Sentry commented 1 month ago

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

A NextJS customer complained on Discord about Overgrouping

They don't have source maps, the error message has a very slight difference due to different status codes in each error message.

Expected Result

The user expects a different issue for 400s, 409s, 504s

Actual Result

Errors of all types of status codes get grouped into a single issue incorrectly

Product Area

Issues

Link

No response

DSN

No response

Version

No response

felixhagspiel commented 1 month ago

to add a bit more context, we are logging errors from axios like this:

axios({
      url: process.env.NEXT_PUBLIC_API_SERVER_URL! + url,
      ...options,
      headers: {
        Authorization: `Bearer ${token}`,
        ...options?.headers,
        'Accept-Language': locale,
      },
    })
      .then((resp) => ({
        error: false,
        data: resp.data as T,
        status: resp.status,
      }))
      .catch((err) => {
        logApiError(err); // here we call logApiError()
        return {
          data: undefined,
          error: err?.response?.data || true,
          status: err?.response?.status,
        };
      });

export const logApiError = (error: any): void => {
  try {
    if (error?.response?.status !== 401) {
      Sentry.captureException(error, {
        extra: {
          // ...
        },
      });
      console.error(`API Error `, error);
    }
  } catch (e) {
    console.error(`Error reporting to Sentry! `, error);
  }
};

Would it make a difference to not catch the error-promise, but wrap the axios call in a try/catch and send the exception to sentry rather than using the error returned from axios?

felixhagspiel commented 1 month ago

We have solved this issue with manually setting custom fingerprints. Ticket can be closed.

Dhrumil-Sentry commented 1 month ago

@felixhagspiel thanks for your feedback, we're keeping this ticket open because we've heard this feedback from other users too and we'd like to figure out a product solution for this case