secret-cipher.test.ts fails on Node 26 linked against OpenSSL 4.1

Open Beginner friendly
#1,937 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
nodejs, typescript
Domain
backend

Research direction

The failing assertions are in apps/api/src/core/tests/secret-cipher.test.ts at lines 28-33 and 45-52. The decryption logic is in apps/api/src/core/secret-cipher.ts, where decipher.final() throws. Run pnpm exec vitest run on the test file under Node 26 with OpenSSL 4.1 to see the new 'bad decrypt' message. Done when the test passes on both OpenSSL 3.x and 4.x, either by wrapping the authentication failure in decryptSecret or by matching both error strings.

Written by the indexing model from the issue text.

Description

Area: API Bug Difficulty: Low Priority: Low

apps/api/src/core/__tests__/secret-cipher.test.ts asserts the exact OpenSSL 3.x error string 'Unsupported state or unable to authenticate data' when AES-256-GCM decryption fails authentication in two tests:

  • decryptSecret > should throw when the key differs, which is what a rotated SECRET_KEY looks like (apps/api/src/core/__tests__/secret-cipher.test.ts:28-33)
  • decryptSecret > should throw when the ciphertext has been tampered with (apps/api/src/core/__tests__/secret-cipher.test.ts:45-52)

Under Node v26.13.1 linked against OpenSSL 4.1.0 (which satisfies root package.json "engines": { "node": "^24.22.1 || >=26.12.1" }), decipher.final() throws:

Error: error:1C800064:Provider routines::bad decrypt

instead of 'Unsupported state or unable to authenticate data', failing pnpm test:coverage.

Reproduction

On a host with Node v26.13.1 (process.versions.openssl === '4.1.0'), run:

pnpm exec vitest run apps/api/src/core/__tests__/secret-cipher.test.ts
Possible fix

Either normalize decipher.final() authentication failures in decryptSecret (apps/api/src/core/secret-cipher.ts) into an application error message independent of the underlying OpenSSL build, or match both OpenSSL 3.x and OpenSSL 4.x GCM authentication error messages in secret-cipher.test.ts.

Dominant language
TypeScript
Stars
119
Forks
19
Avg merge
1d 18h
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DouglasNeuroInformatics/OpenDataCapture

All issues in DouglasNeuroInformatics/OpenDataCapture

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.