Skip to content

chore: ignore sentry errors by regexp#1440

Merged
josephjclark merged 4 commits into
release/nextfrom
ignore-sentry-errors
Jun 9, 2026
Merged

chore: ignore sentry errors by regexp#1440
josephjclark merged 4 commits into
release/nextfrom
ignore-sentry-errors

Conversation

@doc-han

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

Copy link
Copy Markdown
Collaborator

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

@josephjclark josephjclark changed the base branch from main to release/next June 9, 2026 14:36
@josephjclark josephjclark force-pushed the ignore-sentry-errors branch from 7548674 to 67d30e4 Compare June 9, 2026 14:37
@doc-han doc-han force-pushed the ignore-sentry-errors branch from 67d30e4 to 7548674 Compare June 9, 2026 14:41
@josephjclark josephjclark changed the base branch from release/next to main June 9, 2026 14:42
@josephjclark josephjclark force-pushed the ignore-sentry-errors branch from 7548674 to 8124a38 Compare June 9, 2026 14:45
@josephjclark josephjclark changed the base branch from main to release/next June 9, 2026 14:47
@josephjclark josephjclark deleted the branch release/next June 9, 2026 14:48
@github-project-automation github-project-automation Bot moved this from New Issues to Done in Core Jun 9, 2026
@josephjclark josephjclark reopened this Jun 9, 2026
@josephjclark josephjclark force-pushed the ignore-sentry-errors branch from e945e28 to 2a5d14e Compare June 9, 2026 16:31
@josephjclark josephjclark merged commit 8b912fa into release/next Jun 9, 2026
7 checks passed
@josephjclark josephjclark deleted the ignore-sentry-errors branch June 9, 2026 16:41
josephjclark added a commit that referenced this pull request Jun 9, 2026
* create output directory if it doesn't exist (#1452)

* fix(cli): create output directory if it doesn't exist (#1445)

The compile and collections commands threw ENOENT when --output-path
pointed to a directory that hadn't been created yet. Add
mkdir({ recursive: true }) before writeFile in both handlers, matching
the pattern already used in the execute command's serialize-output.ts.

Fixes #859

* changeset

---------

Co-authored-by: Lamine Gueye <[email protected]>

* Fix gitignore cache (#1453)

* fix(cli): fix cache .gitignore written to fs root and undefined workflow name (#1444)

* fix(cli): fix cache .gitignore written to fs root and undefined workflow name

- Replace ensureGitIgnore path-walking logic with a direct getCacheRoot
  helper. The old loop used endsWith('.cli-cache') to find the cache
  root, but if the path never contained that segment (custom cachePath)
  it would walk all the way to '/' and write /.gitignore
- Fall back to 'workflow' when plan.workflow.name is undefined, avoiding
  .cli-cache/undefined directories
- Add cachePath to saveToCache/clearCache options types so custom cache
  paths set by workspace projects are correctly forwarded to getCachePath
- Remove spurious await on the now-synchronous getCachePath call
- Add regression tests covering expressionPath + cacheSteps (the exact
  scenario reported in #669, which had no test coverage)

Fixes #669

* fix test: use correct cache subdir name derived from filename

* refactor(cli): address review feedback on cache fix

- Eliminate getCacheRoot helper: getCachePath(options) with no
  workflowName/stepId already returns the CACHE_DIR root naturally
- Use .filter(Boolean) spread into path.resolve so undefined workflowName
  does not cause ERR_INVALID_ARG_TYPE (path.resolve throws on undefined)
- Keep cachePath in saveToCache/clearCache Pick types so custom paths work
- Rename gitignore test name to be more accurate

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* style(cli): fix prettier formatting

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Revert "style(cli): fix prettier formatting"

This reverts commit 1e47fad.

* style(cli): fix prettier v2 formatting

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor(cli): simplify workflowName fallback per review

Use workflowName ?? '' instead of .filter(Boolean) spread.
path.resolve treats '' as a no-op so undefined workflowName
still resolves to the bare CACHE_DIR root.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>

* clean up test

* changeset

* tidying up

* typing

---------

Co-authored-by: Lamine Gueye <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>

* Merge & Sync improvements (#1450)

* CLI: add --workflows flag to merge and deploy (#1437)

* add --workflows flag

* rename --workflows to --workflow and alias

* changelog

* update tests

* format

* mock: fix an issue where project obejts can get scribbed on

* fix tests

* update integration tests

* improve error messages for invalid workspace

* better diverence message

* Fix incorrect divergence warnings on checkout (#1446)

* improve error messages for invalid workspace

* better diverence message

* add failing test and notes

* project: set the alias on a checked out project

* fix divergence on checkout

* fixes for tests

* fix tests and enable project alias to be null

* update tests

* update more tests

* relax alias lookup to fix tests

* when merging, force-checkout the result

* remove comment

* types

* fix one more test

* update test

* hide merge command

* chore: ignore sentry errors by regexp (#1440)

* feat: ignore sentry errors by regexp

* chore: remove debug

* feat: add severity override to ignored errors

* changeset

---------

Co-authored-by: Joe Clark <[email protected]>

* versions

---------

Co-authored-by: Lamine Gueye <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Farhan Y. <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Worker: don't report oauth errors to sentry

3 participants