Skip to content

fix: handle invalid luhn checksum input#2544

Open
suzunn wants to merge 1 commit into
gchq:masterfrom
suzunn:fix-luhn-checksum-invalid-input
Open

fix: handle invalid luhn checksum input#2544
suzunn wants to merge 1 commit into
gchq:masterfrom
suzunn:fix-luhn-checksum-invalid-input

Conversation

@suzunn

@suzunn suzunn commented Jun 10, 2026

Copy link
Copy Markdown

Problem

Luhn Checksum currently lets invalid input characters escape as a raw JavaScript error when the character is not valid for the selected radix. For example, Luhn_Checksum(4) with input o reports Character: o is not valid in radix 4. as an unhandled error.

Solution

I wrapped the checksum/check-digit calculation in the operation runner and rethrow validation failures as OperationError, matching the existing controlled operation error path used for invalid radix arguments. I also added regression coverage for the radix 4 invalid-character case from #2536.

Fixes #2536.

Testing

  • npx grunt configTests
  • node --no-warnings --no-deprecation --openssl-legacy-provider tests\operations\index.mjs --grep Luhn
  • npx eslint src\core\operations\LuhnChecksum.mjs tests\operations\tests\LuhnChecksum.mjs
  • git diff --check

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

As we are unable to accept contributions unless the CLA has been signed, this PR will be automatically closed if the CLA is not signed within 21 days.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(Luhn Checksum): invalid input cause an unhandled Character: X is not valid in radix N.

3 participants