Skip to content

GH-50109: [C++][Gandiva] Fix incorrect error messages#50110

Open
lriggs wants to merge 1 commit into
apache:mainfrom
lriggs:gandiva-error-msg-bugs
Open

GH-50109: [C++][Gandiva] Fix incorrect error messages#50110
lriggs wants to merge 1 commit into
apache:mainfrom
lriggs:gandiva-error-msg-bugs

Conversation

@lriggs
Copy link
Copy Markdown
Contributor

@lriggs lriggs commented Jun 5, 2026

Rationale for this change

Three small, independent bugs in Gandiva's runtime error messages: in two cases the message misrepresents what actually failed, and in one case a copy-paste error left the wrong function name in a message.

What changes are included in this PR?

1. levenshtein reported OOM as a length error

cpp/src/gandiva/precompiled/string_ops.cc:1738-1742 — when gdv_fn_context_arena_malloc returned null (i.e. memory allocation failed), the function set the error to "String length must be greater than 0". The condition is an OOM, not a length issue. Now reports "LEVENSHTEIN: could not allocate working memory".

2. levenshtein length-bound message was off by one

cpp/src/gandiva/precompiled/string_ops.cc:1702-1708 — the precondition is in1_len < 0 || in2_len < 0, which rejects only negative lengths (zero is valid). The message said "must be greater than 0", implying zero was rejected too. Corrected to "LEVENSHTEIN: input lengths must be non-negative, got <a> and <b>", which now also echoes the offending values.

3. gdv_fn_aes_decrypt reported the wrong direction

cpp/src/gandiva/gdv_function_stubs.cc:411 — inside the AES decrypt function, the OOM message said "Could not allocate memory for returning aes encrypt cypher text". Pure copy-paste from the sibling encrypt function. Corrected the direction wording.

Test updates

cpp/src/gandiva/precompiled/string_ops_test.cc:1133-1135 — the levenshtein test was asserting HasSubstr("String length must be greater than 0"), which was matching the bug message — i.e. the test was effectively verifying the wrong behavior. Updated to assert the corrected message substring.

Are these changes tested?

cd cpp/debug
cmake --build . --target gandiva_shared gandiva-precompiled-test gandiva-internals-test gandiva-projector-test -j4
./debug/gandiva-precompiled-test     # 130/130 pass
./debug/gandiva-internals-test       # 156/156 pass
./debug/gandiva-projector-test       # 218/218 pass

Are there any user-facing changes?

Yes, improved error message accuracy.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

⚠️ GitHub issue #50109 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jun 5, 2026
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.

2 participants