Skip to content

fix(#5798): Cypher string functions reject non-STRING arguments - #5901

Merged
robfrank merged 6 commits into
mainfrom
fix/5798-several-string-functions-silently-coerce
Aug 7, 2026
Merged

robfrank merged 6 commits into
mainfrom
fix/5798-several-string-functions-silently-coerce

Conversation

@robfrank

@robfrank robfrank commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Makes toUpper(), toLower(), trim()/btrim(), lTrim(), rTrim(), split() and replace()
reject arguments outside their declared STRING input domain with a client-facing
CommandSemanticException (400) instead of silently converting any value - INTEGER, BOOLEAN,
LIST<ANY>, ... - to text via Object.toString().

Closes #5798

Motivation

These functions declare a STRING input domain, but their implementation called .toString() on
the argument without checking its runtime type first. That made toUpper(5) observationally
identical to the explicit conversion toUpper(toString(5)), hiding an invalid type usage as an
apparently successful result and diverging from Neo4j, which rejects the non-STRING input as a
type error.

This is the same class of defect already fixed for the numeric family in #5484 and for
head()/last()/tail()/size() in #5476/#5477.

Related issues

Closes #5798. Same class of fix as #5484, #5476 and #5477.

What changed

toString() conversion is still available explicitly, and null still propagates to null per
Cypher semantics.

Test plan

New test class CypherStringFunctionArgumentIssue5798Test:

  • Each of the seven functions rejects a non-STRING INTEGER argument with a
    CommandSemanticException naming the function and STRING; toUpper() additionally covers
    BOOLEAN and LIST<ANY>.
  • null still propagates to null for every affected function.
  • A valid STRING argument still works as before (regression guard).
  • toUpper(toString(5)) still returns "5" (explicit conversion keeps working).
  • The parse-time static check rejects a literal even when no row would reach the projection.
  • A property read whose runtime value is a non-STRING type is rejected too (runtime path).
  • The primary argument is still rejected even when a secondary argument is null (e.g.
    replace(5, null, 'b')), so a null secondary argument cannot mask an out-of-domain primary
    one.
  • The alias spellings (upper, lower, ltrim, rtrim) reject a non-STRING argument too.
  • The 3-argument SQL-style trim(BOTH/LEADING/TRAILING char FROM string) form rejects a
    non-STRING source.

Verified with (see docs/5798-string-function-strict-string-args.md for full detail):

Additional Notes

Breaking change: queries that relied on the old implicit toString() coercion now get a
CommandSemanticException (400) instead of a silently converted string, e.g. RETURN toUpper(5)
used to return "5" and now throws. This is intentional and matches the precedent already set by
#5484 for the numeric family; callers who need the old behavior can request it explicitly with
toString(), e.g. toUpper(toString(5)).

Scope is limited to the primary text argument of each of the seven functions, matching what the
issue reports. Secondary STRING-typed arguments (e.g. split()'s delimiter, replace()'s search
and replacement text) are unchanged and out of scope for this fix. left() and right()
(com.arcadedb.function.text.LeftFunction/RightFunction) have the same class of defect but were
not named in #5798 and are left for a follow-up.

Checklist

  • I have run the build using mvn clean package command
  • My unit tests cover both failure and success scenarios

toUpper(), toLower(), trim()/btrim(), lTrim(), rTrim(), split() and
replace() declare a STRING input domain but implemented it by calling
Object.toString() on the argument, silently converting any value -
INTEGER, BOOLEAN, LIST<ANY>, ... - into text instead of rejecting it.
This made toUpper(5) observationally identical to the explicit
conversion toUpper(toString(5)), hiding invalid type usage as a
"successful" result.

Add CypherFunctionHelper.requireStringArgument(), mirroring the
existing requireNumberArgument/requireListArgument helpers, and use it
in the runtime executors for all seven functions. Extend the
parse-time static check in CypherSemanticValidator so a statically
known non-STRING literal is rejected before the query runs too,
matching the existing #5484/#5477/#5476 precedent for other
type-domain violations.
@mergify

mergify Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 17 complexity

Metric Results
Complexity 17

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review

Nice, well-documented fix with strong test coverage for the primary scenarios. I traced through all seven touched executors against the parse-time validator and found one correctness gap worth addressing before merge.

Bug: the new type check can be silently bypassed when a secondary argument is null

For replace(), split(), and the 2-argument forms of lTrim()/rTrim()/trim()/btrim(), the pre-existing null-check runs before the new requireStringArgument() call, and it short-circuits on any null argument, not just the primary one:

// ReplaceFunction.execute
if (args[0] == null || args[1] == null || args[2] == null)
  return null;
final String source = CypherFunctionHelper.requireStringArgument(args[0], getName());
// LTrimFunction.execute (2-arg form); RTrimFunction and CypherTrimFunction (2-arg) are identical in shape
if (args[0] == null || args[1] == null)
  return null;
final String source = CypherFunctionHelper.requireStringArgument(args[0], getName());

Consequence: replace(5, null, 'b'), split(5, null), and lTrim(5, null) / rTrim(5, null) / trim(5, null) all return null instead of raising CommandSemanticException for the INTEGER primary argument, even though replace(5, 'a', 'b'), split(5, ','), and lTrim(5) are all correctly rejected by this same PR's tests. The type check on the in-scope primary argument only fires when every other argument happens to be non-null, which is exactly the kind of "invalid type usage hiding as an apparently successful result" this PR (and #5798) sets out to eliminate.

This isn't just a style nitpick, it contradicts the ordering convention this codebase already established for the same class of bug in #5484: MathBinaryFunction and RoundFunction deliberately type-check every argument before letting null propagation decide the answer, with an explicit comment ("Both arguments are type-checked before null propagation decides the answer, so an out-of-domain argument is still reported even when the other one happens to be null"). The new code for replace/split/lTrim/rTrim/trim (2-arg) does the opposite for the primary argument.

Worth noting CypherTrimFunction's 3-argument SQL-style form (trim(BOTH x FROM y)) does not have this problem: it validates source unconditionally once it's non-null, before checking whether trimChar is null, so it actually follows the #5484 convention correctly. That inconsistency between the 2-arg and 3-arg forms of the same function is itself a sign the ordering wasn't deliberate.

Suggested fix: check the primary argument's type first, independent of the other arguments' nullness, e.g.

final String source = CypherFunctionHelper.requireStringArgument(args[0], getName());
if (source == null || args[1] == null)
  return null;

None of the 14 new tests in CypherStringFunctionArgumentIssue5798Test exercise a bad-typed primary argument paired with a null secondary argument, so this gap has no regression coverage - worth adding a case per affected function (e.g. replace(5, null, 'b'), split(5, null), lTrim(5, null)).

Everything else looks solid

  • CypherFunctionHelper.requireStringArgument() mirrors the existing requireNumberArgument/requireListArgument helpers correctly (null passthrough, instanceof String check, shared typeMismatch() builder).
  • The parse-time checkStaticallyKnownArgType() extension is correctly scoped to the single-argument call spellings (confirmed it's only invoked when args.size() == 1), so it can't misfire against the 2-arg/3-arg forms.
  • canonicalStringFunctionName()'s alias mapping (toupper/upper -> toUpper, ltrim -> lTrim, btrim -> trim, etc.) matches each executor's actual getName(), and matches the arities registered in FunctionValidator/CypherFunctionFactory - verified this against the source rather than just trusting the PR description.
  • Scoping out secondary STRING-typed arguments (delimiter, search/replacement text, trim character) is a reasonable, clearly-documented boundary that matches the linked issue.
  • Good test structure: reproducers, null propagation, valid-input regression guard, explicit-toString() escape hatch, runtime property-read path, and the parse-time literal path are all covered separately.

Minor

  • The new docs/5798-string-function-strict-string-args.md follows the existing per-issue doc convention already used elsewhere in this repo, so no concern there.

replace(), split(), and the 2-argument forms of lTrim()/rTrim()/trim()/
btrim() checked every argument for null before calling
requireStringArgument() on the primary one, so an out-of-domain primary
argument (e.g. replace(5, null, 'b')) silently returned null instead of
raising the type error whenever a secondary argument was also null.
Reorder so the primary argument is type-checked first, matching the
#5484 convention already used by MathBinaryFunction/RoundFunction.

Adds a regression test covering the gap for all five affected call
sites.
@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review

Went through the diff and read the final state of all touched files (CypherFunctionHelper, the seven function executors, CypherSemanticValidator, and the new test class). Overall this is a well-scoped, well-tested fix that follows the established pattern from issues 5484/5476/5477 closely.

Strengths

  • requireStringArgument() mirrors the existing helpers well. Null propagation vs. type-mismatch is handled the same way as requireNumberArgument/requireListArgument, correctly returning null for null input so Cypher null semantics are preserved.
  • The two-commit structure is good practice. The second commit (55fb0ca) fixes a real ordering bug from the first pass: replace(), split(), and the 2-arg lTrim/rTrim/trim/btrim forms previously null-checked every argument before type-checking the primary one, so replace(5, null, 'b') would have silently returned null instead of raising a type error. Reordering to type-check the primary argument first (matching the MathBinaryFunction/RoundFunction convention from issue 5484) is correct and covered by a dedicated regression test.
  • Parse-time and runtime messages are kept consistent. canonicalStringFunctionName() maps the parser's lower-cased alias (toupper, upper, ltrim, btrim, ...) to the same spelling each executor's getName() reports, so the client sees one message regardless of which check path caught the mistake. I verified this against FunctionValidator/CypherFunctionFactory and the aliasing lines up.
  • Scope is honestly documented and matched by the code: only each function's primary text argument is checked; secondary STRING-typed arguments (delimiter, search/replace text, trim character) and the SQL-style 3-arg trim(BOTH char FROM string) mode/trimChar are correctly left untouched.
  • Blast radius is contained: ToUpperFunction, ToLowerFunction, LTrimFunction, RTrimFunction, ReplaceFunction (com.arcadedb.function.text) and CypherSplitFunction/CypherTrimFunction (opencypher.executor) are only wired up through CypherFunctionFactory, the plain SQL engine has separate implementations, so SQL behavior is unaffected.
  • No new dependency, no leftover System.out debug statements, final used consistently on new locals/params.

Minor observations (not blocking)

  1. btrim() errors always say trim(). CypherTrimFunction.getName() returns "trim" unconditionally (pre-existing, not introduced by this PR), and canonicalStringFunctionName() maps btrim to trim at parse time to stay consistent with that. So btrim(5, null) reports a message naming trim() rather than btrim(). It's internally consistent (both check paths agree, and the new test asserts this exact behavior), but a user who typed btrim might find the message pointing at a different function name mildly confusing. Worth confirming this is intentional rather than an oversight.
  2. Slight domain-check asymmetry between the two check paths: checkStaticallyKnownArgType() accepts any literal instanceof CharSequence as in-domain, while requireStringArgument() at runtime only accepts instanceof String. In practice this shouldn't matter since string literals and STRING-typed property values are always plain java.lang.String, so there's no real gap today, just flagging that the two layers aren't byte-for-byte identical in their type check.
  3. docs/5798-string-function-strict-string-args.md is fine, it follows the repo's existing convention of a per-issue doc under docs/ (5690, 5745, 5788, 5796, 5809 already exist), so no concern there.

Test coverage

CypherStringFunctionArgumentIssue5798Test is thorough: happy path for all seven functions, null propagation, the explicit toString() escape hatch, the parse-time literal check (including the "no row matches" case mirroring Neo4j), the runtime property-read path, and the primary-vs-secondary null ordering gap fixed in the second commit. One optional addition: a case exercising the alias spellings themselves (upper(5), lower(5), ltrim(5)) directly, since canonicalStringFunctionName's alias mapping is currently only exercised implicitly through toUpper/toLower.

No security or performance concerns: the added checks are cheap instanceof tests on the hot path, consistent with the numeric-family precedent, and the error path throws rather than allocating anything expensive.

Covers upper(), lower(), ltrim() and rtrim() rejecting a non-STRING
argument directly, exercising canonicalStringFunctionName()'s alias
mapping rather than only its canonical spelling.
@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review

Solid, well-scoped fix. requireStringArgument() mirrors the existing requireNumberArgument/requireListArgument helpers, the runtime and parse-time checks are kept in sync via canonicalStringFunctionName(), and the primary-argument-before-null-secondary-argument ordering bug found in the first review cycle was fixed correctly across all five affected call sites (replace, split, lTrim/rTrim/btrim 2-arg forms) - I traced each one and the reordering is right.

Correctness

  • CypherFunctionHelper.requireStringArgument() correctly returns null for null (Cypher null propagation) and throws CommandSemanticException (client 400) otherwise - consistent with the existing numeric/list helpers.
  • The 3-arg SQL-style trim(BOTH/LEADING/TRAILING char FROM string) path in CypherTrimFunction was also touched (the source computation moved after the args[2] == null check and now goes through requireStringArgument). I traced it manually and it's correct - e.g. trim(BOTH 'x' FROM 5) will now throw - but it isn't exercised by any test in CypherStringFunctionArgumentIssue5798Test or the pre-existing trim(... FROM ...) tests in CypherFunctionArityRegistryTest/OpenCypherMissingFunctionsTest. Worth a quick regression test since this code path was directly modified.
  • Good catch in review cycle 1 on the null-ordering bug; the fix and its new test (thePrimaryArgumentIsCheckedEvenWhenASecondaryArgumentIsNull) look right.

Minor / non-blocking observations

Style / process

  • Matches repo conventions well: reuses the existing helper pattern instead of introducing a new mechanism, final used consistently, no new dependencies, docs file follows the established docs/<issue>-*.md convention used elsewhere in the repo.
  • This is a behavior change for existing queries that relied on implicit toString() coercion (e.g. toUpper(5) now throws instead of returning "5") - intentional and consistent with the [OpenCypher] abs() returns HTTP 500 for invalid argument instead of client-facing error #5484 precedent, but worth calling out explicitly in the PR/release notes as a breaking change for anyone who might depend on the old silent-coercion behavior.

I reviewed this statically (diff + surrounding code) rather than running the build in this sandbox, so I couldn't independently reproduce the 14/14 pass and full-package regression numbers reported in the PR description, but the logic checks out from a manual trace of every modified call site.

Adds a regression test for trim(BOTH/LEADING/TRAILING char FROM
string) rejecting a non-STRING source, exercising the code path
directly modified in the first commit (CypherTrimFunction's
args.length == 3 branch) that had no dedicated test.

Also updates the PR description with a breaking-change note and a
left()/right() follow-up mention, per review feedback.
@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review: fix(#5798) - Cypher string functions reject non-STRING arguments

Went through the diff (CypherFunctionHelper.requireStringArgument, the seven function executors, the CypherSemanticValidator parse-time check, and the new test class) plus the surrounding call sites (FunctionValidator arity registrations, CypherFunctionFactory registration, the trimFunction grammar/parser to confirm arg ordering for the SQL-style 3-arg trim() form).

Overall

Solid, well-scoped fix that follows the established requireNumberArgument/requireListArgument pattern from #5484/#5476/#5477 closely. requireStringArgument() is a clean, minimal addition, and the parse-time static check mirrors the existing numeric/list precedent so the client sees one consistent error whichever path (parse-time literal vs. runtime value) catches the mistake.

Correctness

  • Verified the primary-argument-before-secondary-null ordering is correctly applied at all five affected call sites (replace, split, lTrim/rTrim 2-arg form, btrim 2-arg form) - replace(5, null, 'b') now throws instead of silently returning null.
  • Traced the 3-argument SQL-style trim(BOTH/LEADING/TRAILING char FROM string) path against the grammar (CypherExpressionBuilder.parseTrimFunction, which builds args as [mode, trimChar, source]) and confirmed CypherTrimFunction's args.length == 3 branch type-checks args[2] (the source) correctly, and does so before the trim-character null check decides the answer.
  • canonicalStringFunctionName() correctly maps alias spellings (upper→toUpper, lower→toLower, ltrim→lTrim, rtrim→rTrim, btrim→trim) so the parse-time and runtime error messages agree regardless of which spelling the caller used.
  • Confirmed these seven functions (com.arcadedb.function.text.* + the two com.arcadedb.query.opencypher.executor.* ones) are registered only in CypherFunctionFactory, i.e. Cypher-only - this doesn't touch the SQL engine's own string functions, so there's no cross-engine regression risk.
  • FunctionValidator's arity registrations (trim 1-3, ltrim/rtrim 1-2, split 2-2, replace 3-3, plus aliases) line up with what each executor's execute() actually handles.

Minor / non-blocking observations

  1. CypherTrimFunction's 3-arg branch could be simplified. It currently does:
    if (args[2] == null)
      return null;
    final String source = CypherFunctionHelper.requireStringArgument(args[2], getName());
    if (trimChar == null)
      return null;
    Since requireStringArgument() already returns null for a null input, this can collapse to match the style of the 1-arg/2-arg branches above it:
    final String source = CypherFunctionHelper.requireStringArgument(args[2], getName());
    if (source == null || trimChar == null)
      return null;
    Purely a readability nit - the current code is correct, just slightly more verbose than necessary.
  2. Scope is clearly documented but worth double-checking intent: secondary STRING-typed arguments (split()'s delimiter, replace()'s search/replacement, the trim-character args) still call .toString() unchecked. The PR body calls this out explicitly as out-of-scope, and left()/right() are noted as a deferred follow-up - that's a reasonable, well-communicated scope boundary rather than an oversight.
  3. docs/5798-string-function-strict-string-args.md's "Results" section says "14/14 pass", but the final test class has 17 @Test methods (after the alias-spelling and 3-arg-trim tests were added in later commits). The per-cycle notes further down the same doc do account for the additions, so this is just a stale summary line, not a functional issue - worth a quick touch-up before merge.
  4. Breaking change is clearly flagged in the PR description (queries relying on implicit toString() coercion, e.g. RETURN toUpper(5), now throw). Given this changes existing observable behavior, it'd be worth confirming there's a CHANGELOG/release-notes entry if the project tracks those for breaking changes, beyond the PR description itself.

Test coverage

Very thorough: covers all seven functions, both the parse-time literal path and the runtime (property-read) path, null propagation, explicit toString() conversion still working, alias spellings, the primary-argument-checked-before-secondary-null ordering, and the 3-arg SQL-style trim() form. No gaps found.

Security / performance

No concerns. requireStringArgument() is an O(1) instanceof check consistent with the existing numeric/list helpers, and no new dependencies or unsafe patterns were introduced.

Nice work - this closes the gap cleanly and consistently with the established pattern for the numeric and list function families.

CypherTrimFunction's 3-arg branch collapses the redundant explicit
args[2] == null check into requireStringArgument()'s own null
handling, matching the style already used by the 1-arg/2-arg branches.
No behavior change.

Also corrects the tracking doc's stale "14/14 pass" test count (the
class grew to 17 tests across review cycles 2-3).
@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review

Went through the diff, the new test class, and the affected call sites (CypherFunctionHelper, the seven function executors, CypherSemanticValidator, plus left()/right() and CypherFunctionFactory for context). Note: I could not run mvn verify/tests myself in this sandbox (build tooling was blocked), so this is a static review; the PR description's own reported test run (337 test classes / 7652 tests, 0 failures) plus the tracking doc's TDD red→green log stand in for that.

Overall: this is a clean, well-scoped fix. It correctly mirrors the established requireNumberArgument/requireListArgument pattern with requireStringArgument, the null-before-type-check ordering bug from cycle 1 is genuinely fixed at all five affected call sites (ReplaceFunction, CypherSplitFunction, LTrimFunction, RTrimFunction, CypherTrimFunction's 2-arg form), and the parse-time/runtime error messages are kept consistent via canonicalStringFunctionName(). I didn't find any new correctness bugs.

Things I checked and confirmed correct

  • canonicalStringFunctionName()'s alias mapping (toupper/upper→toUpper, tolower/lower→toLower, ltrim→lTrim, rtrim→rTrim, btrim→trim) matches CypherFunctionFactory's own alias resolution (case "trim","btrim" -> new CypherTrimFunction(), etc.) and each executor's getName() — so the parse-time and runtime paths report the same function name in the exception message.
  • checkStaticallyKnownArgType is only invoked when args.size() == 1 (see checkFunctionArgTypes), which correctly matches the PR's stated scope of "the single-argument spelling" for the new STRING cases — split()/replace() never have a 1-arg form, so relying on the runtime check alone for them is right, not an oversight.
  • left()/right() do indeed have the identical .toString()-coercion defect and are correctly called out as an explicit, named follow-up rather than silently left inconsistent.
  • The 3-arg SQL-style trim(BOTH/LEADING/TRAILING char FROM string) path (CypherTrimFunction, args.length == 3) now type-checks args[2] before the trimChar == null short-circuit, and the cycle-4 simplification collapsing the redundant args[2] == null check into requireStringArgument's own null handling is correct and reads more consistently with the 1-/2-arg branches above it.

Minor, non-blocking observation

checkStaticallyKnownArgType has a pre-existing early return above the switch:

// A literal holding a collection is a LIST, which every function handled below accepts.
if (literal instanceof Collection || (literal != null && literal.getClass().isArray()))
  return;

That comment is no longer accurate now that STRING-only functions (toUpper, trim, etc.) share this switch — they do not accept a LIST. In practice this looks unreachable today: a bracketed list literal like [1,2] parses to a ListExpression, not a LiteralExpression, so literal never actually holds a Collection here for that syntax, and the runtime requireStringArgument check still catches a real list value in the normal (non-dead-row) case. The only theoretical gap is the same class of edge case the parse-time check exists for elsewhere: MATCH (n) WHERE false RETURN toUpper(<literal list>) skipping the parse-time rejection if some future literal-folding path ever produces a LiteralExpression wrapping a Collection. Not something this PR needs to fix, but worth a one-line comment update or a follow-up note if the CypherStringFunctionArgumentIssue5798Test's parse-time coverage is later extended.

Test coverage

The new CypherStringFunctionArgumentIssue5798Test (17 tests) is thorough: all seven functions, both alias spellings and the SQL-style 3-arg trim() form, the null-secondary-argument ordering regression, null propagation, valid-string regression, the runtime property-read path, and the parse-time literal path. Good balance of unit-level and query-level assertions, and the single()/consume() helpers keep the test bodies readable.

Style / conventions

  • Uses final consistently, no unnecessary curly braces, imports the classes it needs rather than using FQNs — matches the repo's stated conventions.
  • No new dependencies, no System.out debug leftovers spotted.
  • The per-issue docs/5798-*.md tracking file follows the existing convention already used for other recent issues in docs/.

Nice, incremental piece of work — consistent with the precedent set by #5484/#5476/#5477, and the multiple review cycles already reflected in the tracking doc show the null-ordering bug and the missing 3-arg-trim/alias test coverage were caught and fixed along the way. No blocking issues from my pass.

@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review

Clean, well-scoped fix that closes #5798 consistently with the precedent set by #5484/#5476/#5477. Went through the diff (7 functions + validator + helper + new test class) and the existing docs/5798-... tracking doc.

Correctness

  • CypherFunctionHelper.requireStringArgument() mirrors requireNumberArgument/requireListArgument exactly (null-propagates, instanceof String pattern match, shared typeMismatch() builder) - good reuse of the established pattern.
  • The primary-argument-before-null-check reordering in ReplaceFunction, CypherSplitFunction, LTrimFunction/RTrimFunction/CypherTrimFunction (2-arg form) is correct and matches the MathBinaryFunction/RoundFunction convention from [OpenCypher] abs() returns HTTP 500 for invalid argument instead of client-facing error #5484, so replace(5, null, 'b') now correctly reports a type error instead of returning null.
  • canonicalStringFunctionName() maps the parser's lower-cased alias names back to each executor's getName() spelling (toupper/upper -> toUpper, ltrim -> lTrim, btrim -> trim, etc.) - verified this matches every getName() implementation, so the parse-time and runtime error messages stay identical regardless of which check catches the mistake.

Minor gap (non-blocking)
checkStaticallyKnownArgType() only inspects arg instanceof LiteralExpression (plus a separate MapExpression check). A list literal parses to ListExpression, not LiteralExpression, so literal stays null and the method returns early before reaching the new toupper/tolower/trim/... switch cases. Practical effect:

MATCH (n) WHERE false RETURN toUpper([1,2])

will not be rejected at parse time (unlike toUpper(5), which is caught statically), even though the same query executes and correctly throws once a row actually reaches the projection (per toUpperOfListIsAClientTypeError, which doesn't use a WHERE false guard so it never exercises this path). This slightly undercuts the stated "matches Neo4j, fails even when no row matches" goal for the LIST case specifically. It's a pre-existing limitation of checkStaticallyKnownArgType (the same gap exists for head()/last()/tail()'s list-literal handling), not a regression introduced here, and runtime correctness is unaffected - just flagging it since the PR explicitly added isMap handling for the MAP case but the equivalent LIST case silently doesn't fire. Might be worth a one-line comment noting the limitation, or a follow-up if parse-time completeness matters here.

Test coverage
Thorough - 17 tests covering all seven functions, alias spellings, the 3-arg SQL-style trim() form, null propagation, the primary-argument-before-null-secondary ordering bug, the runtime property-read path, and the parse-time literal path. Nice catch on the replace(5, null, 'b') gap during the earlier review cycles.

Other notes

No blocking issues. Nice work.

@robfrank
robfrank merged commit c2476f1 into main Aug 7, 2026
22 of 27 checks passed
mergify Bot added a commit that referenced this pull request Aug 16, 2026
Bumps `junit.jupiter.version` from 6.1.2 to 6.1.3.
Updates `org.junit:junit-bom` from 6.1.2 to 6.1.3
Release notes

*Sourced from [org.junit:junit-bom's releases](https://github.com/junit-team/junit-framework/releases).*

> JUnit 6.1.3 = Platform 6.1.3 + Jupiter 6.1.3 + Vintage 6.1.3
>
> See [Release Notes](https://docs.junit.org/6.1.3/release-notes.html).
>
> **Full Changelog**: <junit-team/junit-framework@r6.1.2...r6.1.3>


Commits

* [`f59f60d`](junit-team/junit-framework@f59f60d) Release 6.1.3
* [`cd8ec92`](junit-team/junit-framework@cd8ec92) Finalize 6.1.3 release notes
* [`c8729f2`](junit-team/junit-framework@c8729f2) Restore compatibility with GraalVM 25 ([#5901](https://redirect.github.com/junit-team/junit-framework/issues/5901))
* [`ddc9e74`](junit-team/junit-framework@ddc9e74) Update graalvm/setup-graalvm action to v1.6.4 ([#5959](https://redirect.github.com/junit-team/junit-framework/issues/5959))
* [`fe2c52a`](junit-team/junit-framework@fe2c52a) Update plugin org.graalvm.buildtools.native to v1.1.7 ([#5923](https://redirect.github.com/junit-team/junit-framework/issues/5923))
* [`62afc02`](junit-team/junit-framework@62afc02) Delay GraalVM plugin updates for 3 days
* [`0cc2902`](junit-team/junit-framework@0cc2902) Skip `graalVmTest` task if GraalVM env vars are not set
* [`f6bbfc5`](junit-team/junit-framework@f6bbfc5) Move GraalVM tests to separate test task ([#5903](https://redirect.github.com/junit-team/junit-framework/issues/5903))
* [`e87e052`](junit-team/junit-framework@e87e052) Update plugin org.graalvm.buildtools.native to v1.1.6 ([#5899](https://redirect.github.com/junit-team/junit-framework/issues/5899))
* [`1cd56df`](junit-team/junit-framework@1cd56df) Update plugin org.graalvm.buildtools.native to v1.1.5 ([#5880](https://redirect.github.com/junit-team/junit-framework/issues/5880))
* Additional commits viewable in [compare view](junit-team/junit-framework@r6.1.2...r6.1.3)
  
Updates `org.junit.jupiter:junit-jupiter` from 6.1.2 to 6.1.3
Release notes

*Sourced from [org.junit.jupiter:junit-jupiter's releases](https://github.com/junit-team/junit-framework/releases).*

> JUnit 6.1.3 = Platform 6.1.3 + Jupiter 6.1.3 + Vintage 6.1.3
>
> See [Release Notes](https://docs.junit.org/6.1.3/release-notes.html).
>
> **Full Changelog**: <junit-team/junit-framework@r6.1.2...r6.1.3>


Commits

* [`f59f60d`](junit-team/junit-framework@f59f60d) Release 6.1.3
* [`cd8ec92`](junit-team/junit-framework@cd8ec92) Finalize 6.1.3 release notes
* [`c8729f2`](junit-team/junit-framework@c8729f2) Restore compatibility with GraalVM 25 ([#5901](https://redirect.github.com/junit-team/junit-framework/issues/5901))
* [`ddc9e74`](junit-team/junit-framework@ddc9e74) Update graalvm/setup-graalvm action to v1.6.4 ([#5959](https://redirect.github.com/junit-team/junit-framework/issues/5959))
* [`fe2c52a`](junit-team/junit-framework@fe2c52a) Update plugin org.graalvm.buildtools.native to v1.1.7 ([#5923](https://redirect.github.com/junit-team/junit-framework/issues/5923))
* [`62afc02`](junit-team/junit-framework@62afc02) Delay GraalVM plugin updates for 3 days
* [`0cc2902`](junit-team/junit-framework@0cc2902) Skip `graalVmTest` task if GraalVM env vars are not set
* [`f6bbfc5`](junit-team/junit-framework@f6bbfc5) Move GraalVM tests to separate test task ([#5903](https://redirect.github.com/junit-team/junit-framework/issues/5903))
* [`e87e052`](junit-team/junit-framework@e87e052) Update plugin org.graalvm.buildtools.native to v1.1.6 ([#5899](https://redirect.github.com/junit-team/junit-framework/issues/5899))
* [`1cd56df`](junit-team/junit-framework@1cd56df) Update plugin org.graalvm.buildtools.native to v1.1.5 ([#5880](https://redirect.github.com/junit-team/junit-framework/issues/5880))
* Additional commits viewable in [compare view](junit-team/junit-framework@r6.1.2...r6.1.3)
  
Updates `org.junit.vintage:junit-vintage-engine` from 6.1.2 to 6.1.3
Release notes

*Sourced from [org.junit.vintage:junit-vintage-engine's releases](https://github.com/junit-team/junit-framework/releases).*

> JUnit 6.1.3 = Platform 6.1.3 + Jupiter 6.1.3 + Vintage 6.1.3
>
> See [Release Notes](https://docs.junit.org/6.1.3/release-notes.html).
>
> **Full Changelog**: <junit-team/junit-framework@r6.1.2...r6.1.3>


Commits

* [`f59f60d`](junit-team/junit-framework@f59f60d) Release 6.1.3
* [`cd8ec92`](junit-team/junit-framework@cd8ec92) Finalize 6.1.3 release notes
* [`c8729f2`](junit-team/junit-framework@c8729f2) Restore compatibility with GraalVM 25 ([#5901](https://redirect.github.com/junit-team/junit-framework/issues/5901))
* [`ddc9e74`](junit-team/junit-framework@ddc9e74) Update graalvm/setup-graalvm action to v1.6.4 ([#5959](https://redirect.github.com/junit-team/junit-framework/issues/5959))
* [`fe2c52a`](junit-team/junit-framework@fe2c52a) Update plugin org.graalvm.buildtools.native to v1.1.7 ([#5923](https://redirect.github.com/junit-team/junit-framework/issues/5923))
* [`62afc02`](junit-team/junit-framework@62afc02) Delay GraalVM plugin updates for 3 days
* [`0cc2902`](junit-team/junit-framework@0cc2902) Skip `graalVmTest` task if GraalVM env vars are not set
* [`f6bbfc5`](junit-team/junit-framework@f6bbfc5) Move GraalVM tests to separate test task ([#5903](https://redirect.github.com/junit-team/junit-framework/issues/5903))
* [`e87e052`](junit-team/junit-framework@e87e052) Update plugin org.graalvm.buildtools.native to v1.1.6 ([#5899](https://redirect.github.com/junit-team/junit-framework/issues/5899))
* [`1cd56df`](junit-team/junit-framework@1cd56df) Update plugin org.graalvm.buildtools.native to v1.1.5 ([#5880](https://redirect.github.com/junit-team/junit-framework/issues/5880))
* Additional commits viewable in [compare view](junit-team/junit-framework@r6.1.2...r6.1.3)
  
Updates `org.junit.jupiter:junit-jupiter-params` from 6.1.2 to 6.1.3
Release notes

*Sourced from [org.junit.jupiter:junit-jupiter-params's releases](https://github.com/junit-team/junit-framework/releases).*

> JUnit 6.1.3 = Platform 6.1.3 + Jupiter 6.1.3 + Vintage 6.1.3
>
> See [Release Notes](https://docs.junit.org/6.1.3/release-notes.html).
>
> **Full Changelog**: <junit-team/junit-framework@r6.1.2...r6.1.3>


Commits

* [`f59f60d`](junit-team/junit-framework@f59f60d) Release 6.1.3
* [`cd8ec92`](junit-team/junit-framework@cd8ec92) Finalize 6.1.3 release notes
* [`c8729f2`](junit-team/junit-framework@c8729f2) Restore compatibility with GraalVM 25 ([#5901](https://redirect.github.com/junit-team/junit-framework/issues/5901))
* [`ddc9e74`](junit-team/junit-framework@ddc9e74) Update graalvm/setup-graalvm action to v1.6.4 ([#5959](https://redirect.github.com/junit-team/junit-framework/issues/5959))
* [`fe2c52a`](junit-team/junit-framework@fe2c52a) Update plugin org.graalvm.buildtools.native to v1.1.7 ([#5923](https://redirect.github.com/junit-team/junit-framework/issues/5923))
* [`62afc02`](junit-team/junit-framework@62afc02) Delay GraalVM plugin updates for 3 days
* [`0cc2902`](junit-team/junit-framework@0cc2902) Skip `graalVmTest` task if GraalVM env vars are not set
* [`f6bbfc5`](junit-team/junit-framework@f6bbfc5) Move GraalVM tests to separate test task ([#5903](https://redirect.github.com/junit-team/junit-framework/issues/5903))
* [`e87e052`](junit-team/junit-framework@e87e052) Update plugin org.graalvm.buildtools.native to v1.1.6 ([#5899](https://redirect.github.com/junit-team/junit-framework/issues/5899))
* [`1cd56df`](junit-team/junit-framework@1cd56df) Update plugin org.graalvm.buildtools.native to v1.1.5 ([#5880](https://redirect.github.com/junit-team/junit-framework/issues/5880))
* Additional commits viewable in [compare view](junit-team/junit-framework@r6.1.2...r6.1.3)
  
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
tae898 pushed a commit to humemai/arcadedb-embedded-python that referenced this pull request Aug 23, 2026
…ion as HTTP 500 for non-numeric length/start arguments

RETURN left('a', []), right('a', []) and substring('aa', 0, []) reached an
unchecked (Number) args[i] cast on the length/start argument, so a LIST (or
any other non-numeric value) threw a raw java.lang.ClassCastException that
escaped as HTTP 500 "Error on transaction commit" instead of a client-facing
type error, matching Neo4j/Memgraph/FalkorDB which all reject it as a type
error (22N27 in Neo4j).

LeftFunction, RightFunction, CypherSubstringFunction (and its unregistered
twin SubstringFunction) now resolve their numeric argument(s) through the
existing CypherFunctionHelper.requireNumberArgument() helper, the same
runtime check already used by the pure-numeric family (ArcadeData#5484). Extended
NumericSignature with a startArg position so the parse-time static check
(CypherSemanticValidator.checkStaticallyKnownNumericArgs) also covers these
three functions' trailing numeric arguments without misclassifying their
leading STRING argument, so a literal LIST is rejected before the query
runs, same as the rest of the numeric family.

The primary STRING argument of left()/right()/substring() is untouched:
ArcadeData#5901 named it as a follow-up left out of ArcadeData#5798's scope, and ArcadeData#6609 is only
about the numeric argument.
oc007us pushed a commit to oc007us/arcadedb-grpc that referenced this pull request Aug 25, 2026
… positions of string functions

Issue ArcadeData#5798 (fixed by PR ArcadeData#5901) made split(), replace(), trim()/btrim(),
lTrim() and rTrim() reject a non-STRING value in their primary argument
position with a client-facing type error. The remaining STRING-typed
argument positions of the same functions - split()'s delimiter,
replace()'s search and replacement text, and the trim-character argument
of trim()/btrim()/lTrim()/rTrim() - still silently coerced any value via
toString(). char.length()/char_length() was not covered by ArcadeData#5798 at all.

Apply CypherFunctionHelper.requireStringArgument() to those remaining
positions, the same helper ArcadeData#5798 introduced for the primary argument, so
every STRING-typed argument position now follows the same policy.
@robfrank
robfrank deleted the fix/5798-several-string-functions-silently-coerce branch August 26, 2026 09:10
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.

Several string functions silently coerce non-STRING inputs instead of raising a type error

1 participant