Skip to content

fix(ws-worker): suppress credential environment mismatch from sentry - #1534

Closed
CaptainAni187 wants to merge 1 commit into
OpenFn:mainfrom
CaptainAni187:fix/ignore-credential-environment-mismatch
Closed

CaptainAni187 wants to merge 1 commit into
OpenFn:mainfrom
CaptainAni187:fix/ignore-credential-environment-mismatch

Conversation

@CaptainAni187

Copy link
Copy Markdown

Closes #1460

Adds Credential environment mismatch to IGNORED_ERROR_PATTERNS, following the OAuth token has expired entry added in #1440.

export const IGNORED_ERROR_PATTERNS: IgnoredError[] = [
  { pattern: /OAuth token has expired/i, severity: 'crash' },
  { pattern: /Credential environment mismatch/i },
];

On the missing severity

The OAuth entry carries severity: 'crash', which onRunError uses to override the exit reason. I deliberately left it off here.

The issue asks for this to be suppressed from sentry, and matchesIgnoredError alone does that — getIgnoredErrorSeverity is a separate lookup, and onRunError only overrides when it returns something. So omitting it keeps the change to exactly what was asked and leaves the reason Lightning receives untouched. If you do want an override, say which reason and it's a one-line addition; I did not want to change what the user sees reported without being asked.

On the wider point in the thread

@josephjclark noted that the more important problem is differentiating these in sentry, since LightningSocketError is generic and sentry lumps everything together. That is a bigger change than this and I have not attempted it — this PR only stops this particular message from being reported.

Tests

src/util/ignored-errors.ts had no tests, so this adds the first ones: both patterns, the case-insensitive match, an unrelated message, empty and nullish input, and the severity lookup for both entries — including that a credential mismatch returns no override, which pins the decision above.

  • test/util: 75 passing, up from 67. The 4 failures, 1 skip and 3 uncaught exceptions in that directory are identical before and after this change.
  • tsc --noEmit: output identical before and after (the existing errors are unbuilt workspace deps and some any parameters in wake-up.test.ts).
  • Reverting only the new pattern fails exactly the two credential tests.

A project whose environment has no matching credential environment raises
`Credential environment mismatch`. That is a configuration mistake for the
user to fix, and the message already tells them how, so it should not be
reported as a worker fault.

Adds the pattern to IGNORED_ERROR_PATTERNS, following the OAuth expiry
entry. No severity override is set, so the exit reason is unchanged and only
the sentry report is suppressed.

Also adds the first tests for this module, covering both patterns, the
case-insensitive match, nullish input and the severity lookup.
@CaptainAni187

Copy link
Copy Markdown
Author

Note on the red integration_test job — it doesn't look related to this change.

The worker integration suite hangs rather than fails:

48 tests passed
4 tests skipped
3 tests remained pending after a timeout
Failed

Nothing errors; three tests just never resolve and ava times out. That's the same open-handle symptom described in #1321 ("some open loop is keeping the process alive").

It also isn't specific to forks or to these PRs — #1527 and #1530, both branched inside this repo, fail the same job, while #1528, #1529, #1532 and #1533 pass it. Looks intermittent.

Unit tests and type-checks for the packages touched here are green locally, and identical to a clean checkout.

@josephjclark

Copy link
Copy Markdown
Collaborator

Thanks for this @CaptainAni187 🎉

I'm a bit torn on the tests. They're not very valuable because they're mostly just asserting on basic regex patterns. It's 43 lines of bloat.

I'm planning a release today so I'll probably just merge this in. I might remove the tests, maybe it's better than nothing 🤔

For the record, pasting test suite results into the PR body is pointless, misleading, potentialy dangerous, and kinda annoying. We have automated test suites which tell is if tests are passing. I'll take those over plain text any day.

Please carefully review AI generated PR summaries and make sure to remove irrelevant or misleading information. Humans have to read this stuff and make decisions based on it.

@CaptainAni187

Copy link
Copy Markdown
Author

Both fair. Please drop the tests, they assert the regex engine more than the behaviour and aren't worth 43 lines to carry.

Point taken on the pasted test output too. I'll stop putting it in PR bodies and trim it from my open ones.

@josephjclark

Copy link
Copy Markdown
Collaborator

Closing in favour of #1550

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worker: ignore sentry errors Credential environment mismatch

2 participants