Skip to content

chore: ignore sentry errors by regexp#1440

Open
doc-han wants to merge 2 commits into
mainfrom
ignore-sentry-errors
Open

chore: ignore sentry errors by regexp#1440
doc-han wants to merge 2 commits into
mainfrom
ignore-sentry-errors

Conversation

@doc-han
Copy link
Copy Markdown
Collaborator

@doc-han doc-han commented Jun 3, 2026

Short Description

This PR allows us to ignore specific errors from going through sentry.
We currently don't want Oauth error to pass through sentry. hence we use a beforeSend hook in sentry to filter the errors

(in the image below, the error is intercepted and logged to not be reported to sentry)
ha

Fixes #1429

Implementation Details

A more detailed breakdown of the changes, including motivations (if not provided in the issue).

QA Notes

On Lighting there's a branch that simulates Oauth always failing
Branch: https://github.com/OpenFn/lightning/tree/ignore-sentry-errors (ignore-sentry-errors)

  1. Run lighTning without a work (That's with RTM=false)
  2. Build and run the worker pointing to that lightning server (remember to set the secret to match that of lightning)
  3. To see Sentry debug logs, update the code to have debug:true at
    Sentry.init({
    environment: options.sentryEnv,
    dsn: options.sentryDsn,
    beforeSend(event, hint) {
    const error = hint.originalException as Error | undefined;
    const message = error?.message ?? event.message ?? '';
    if (IGNORED_ERROR_PATTERNS.some((pattern) => pattern.test(message))) {
    return null;
    }
    return event;
    },
    });
  4. Create a workflow and pick a credential for one of the nodes in lightning
  5. Run the workflow and then check the worker logs
  6. You should see the Oauth error captured in the logs but sentry debug logs should notify that this specific error isn't going to be reported.

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Release branch checklist

Delete this section if this is not a release PR.

If this IS a release branch:

  • Run pnpm changeset version from root to bump versions
  • Run pnpm install
  • Commit the new version numbers
  • Run pnpm changeset tag to generate tags
  • Push tags git push --tags

Tags may need updating if commits come in after the tags are first generated.

@github-project-automation github-project-automation Bot moved this to New Issues in Core Jun 3, 2026
@doc-han doc-han changed the title feat: ignore sentry errors by regexp chore: ignore sentry errors by regexp Jun 3, 2026
@doc-han doc-han marked this pull request as ready for review June 3, 2026 09:15
@doc-han doc-han requested a review from josephjclark June 3, 2026 09:17
@josephjclark
Copy link
Copy Markdown
Collaborator

@doc-han this looks great, I love the approach

One adjustment I'd like (which might change the approach) is that ideally the workflow should exit with state Crashed

image

I'd also love to see this reported on the status-codes docs page

image

Can you have a think about what it would take to do that? I think it means you still might have to catch the exception earlier in the process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

Worker: don't report oauth errors to sentry

3 participants