Skip to content

fix(A1Z26): return empty string instead of empty array for empty input#2257

Merged
GCHQDeveloper581 merged 2 commits intogchq:masterfrom
brick-pixel:fix/a1z26-empty-input-return-type
Mar 19, 2026
Merged

fix(A1Z26): return empty string instead of empty array for empty input#2257
GCHQDeveloper581 merged 2 commits intogchq:masterfrom
brick-pixel:fix/a1z26-empty-input-return-type

Conversation

@brick-pixel
Copy link
Contributor

What

Changed the early return for empty input in A1Z26 Cipher Decode from [] to "".

Why

The operation declares this.outputType = "string", but the empty input check on line 80 returns an empty array:

if (input.length === 0) {
    return [];  // violates outputType: "string"
}

This causes a type mismatch that can break downstream operations expecting a string.

Changes

File: src/core/operations/A1Z26CipherDecode.mjs

 if (input.length === 0) {
-    return [];
+    return "";
 }

Fixes #2248

The A1Z26 Cipher Decode operation declares outputType as 'string' but
returned an empty array for empty input, violating its type contract.

Fixes gchq#2248
@CLAassistant
Copy link

CLAassistant commented Mar 16, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@GCHQDeveloper581 GCHQDeveloper581 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you add a test that would fail without this change and pass with it.

@brick-pixel
Copy link
Contributor Author

Added tests in 06cc1b4:

  • A1Z26 Cipher Decode: basic decode — verifies normal decoding (8 5 12 12 15hello)
  • A1Z26 Cipher Decode: empty input returns empty string — this test fails without the fix (returns [] instead of "") and passes with it

Test file: tests/operations/tests/A1Z26CipherDecode.mjs
Import added to: tests/operations/index.mjs

@GCHQDeveloper581 GCHQDeveloper581 merged commit eef8d55 into gchq:master Mar 19, 2026
2 checks passed
@GCHQDeveloper581
Copy link
Contributor

Thanks for your contribution!

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.

Bug report: A1Z26 Cipher Decode returns wrong type for empty input

3 participants