Skip to content

fix(#5794): range() zero step, invalid date()/datetime(), non-numeric point() coordinates return HTTP 400 - #5909

Merged
robfrank merged 2 commits into
mainfrom
fix/5794-cypher-function-arg-validation-500
Aug 7, 2026
Merged

robfrank merged 2 commits into
mainfrom
fix/5794-cypher-function-arg-validation-500

Conversation

@robfrank

@robfrank robfrank commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Fixes four Cypher argument-validation paths that returned HTTP 500 (CommandExecutionException) instead of a client-facing HTTP 400 (CommandSemanticException):

  • range() with a zero step
  • date() with a string that parses as neither a date nor a timezone
  • datetime() with a string that parses as neither a datetime nor a timezone
  • point() with a non-numeric coordinate (both branches of the shared coerceCoordinate() guard: a non-numeric String and a value that is neither a Number nor a numeric-looking String)

Each failure is determined entirely by the supplied query arguments and cannot succeed when retried unchanged, so it belongs to the same class of client-caused error already fixed for the neighboring functions in #5484 (abs()), #5296 (left()/right()) and #5545 (arithmetic errors). Only the exception class changes; the existing descriptive messages are unchanged.

Closes #5794

Motivation

A systematic function x invalid-input scan (reported in #5794) found these four paths still reaching the unclassified HTTP 500 path, causing clients to see a misleading internal-server-error status for a deterministic input mistake, which may trigger unnecessary retries or false operational alerts.

Related issues

Closes #5794

Same class of fix as #5484, #5296, #5545.

Additional Notes

Scope is intentionally limited to the four paths named in the issue's reproduction steps. While reproducing the bug I found the same CommandExecutionException-for-a-client-error defect in three sibling temporal constructors (localdatetime(), localtime(), time()) and in a few other point() structural-validation branches (missing x/y or longitude/latitude, non-map argument, non-numeric srid). Those are out of scope for this issue and are recommended as a follow-up.

Test plan

  • New regression test engine/src/test/java/com/arcadedb/query/opencypher/CypherFunctionArgumentValidationIssue5794Test.java reproduces all four named paths (five call sites) and asserts CommandSemanticException, plus a valid-input control test.
  • Confirmed all five reproducer tests failed against main before the fix (asserting CommandExecutionException was thrown instead), proving the bug.
  • mvn -pl engine -am test -Dtest=CypherFunctionArgumentValidationIssue5794Test passes (6/6) after the fix.
  • Broader related-test pass with no regressions: CypherNumericFunctionArgumentIssue5484Test, CypherFollowUpsIssue5602Test, CypherOptionalArgumentNullIssue5629Test, OpenCypherSpatialFunctionsComprehensiveTest, CypherFunctionFactoryExtendedTest, CypherFunctionArityRegistryTest.
  • mvn -pl engine -am compile succeeds.

Checklist

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

… non-numeric point() coordinates return HTTP 400

Four Cypher argument-validation paths threw a bare CommandExecutionException
(HTTP 500) instead of CommandSemanticException (HTTP 400), even though each
failure is determined entirely by the supplied query arguments: range() with
a zero step, date()/datetime() with an unparseable string, and point() with
a non-numeric coordinate. Same class of fix as #5484, #5296 and #5545.
@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

codacy-production Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage 100.00% diff coverage · -6.84% coverage variation

Metric Results
Coverage variation ✅ -6.84% coverage variation
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (6bbb0e7) 152707 117904 77.21%
Head commit (fcc6f20) 185053 (+32346) 130220 (+12316) 70.37% (-6.84%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#5909) 5 5 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

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

Small, well-scoped fix. Verified the core claim against the current handler code: CommandSemanticException extends CommandParsingException, and AbstractServerHttpHandler special-cases CommandParsingException (both the direct-throw arm and the wrapped-as-cause arm) to HTTP 400, while a bare CommandExecutionException falls through to the generic 500 branch. So the exception-class swap does what the PR claims, and it's the same pattern already used elsewhere in RangeFunction.java (issue #5477) for the neighboring integer/type-mismatch and max-range-size checks in the same file - good consistency.

Code quality

  • Changes are surgical: only the exception class at each of the 5 throw sites, no message or behavior changes. Comments explain why (client error vs. server fault), which fits the non-obvious-rationale bar.
  • RangeFunction.java's now-unused CommandExecutionException import was correctly dropped; CypherPointFunction.java's import is correctly kept since three sibling validation branches (non-map argument, missing x/y or longitude/latitude, non-numeric srid) still legitimately use it and are explicitly called out as out-of-scope follow-up work.
  • Javadoc on CypherPointFunction and coerceCoordinate() was updated to match the new exception type - nice, avoids stale docs.

Scope

Tests

  • CypherFunctionArgumentValidationIssue5794Test covers all 5 throw sites plus a valid-input control, following the existing extends TestHelper / database.query("opencypher", ...) pattern used by neighboring Cypher tests. Good regression coverage for the fix itself.
  • Minor: validInputsStillSucceed()'s range assertion (.toString()).contains("1", "5")) is a fairly weak check on the lazy LongRangeList's string form rather than asserting on materialized contents - pre-existing weak-assertion style elsewhere in the suite though, not a blocker.

Docs

  • The new docs/5794-cypher-function-arg-validation-500.md is thorough but largely duplicates the PR description; given docs/ already has several of these per-issue writeups (5788, 5796, 5801, ...), this matches established repo convention rather than being an outlier.

Performance/security: none - this only changes which exception subclass is thrown on already-invalid input, no new allocations or hot-path changes.

Didn't find any bugs. I wasn't able to run mvn in this sandbox to independently execute the test suite, but the diff logic checks out against the actual HTTP-handler exception-mapping code, and the PR description reports the reproducer tests failing pre-fix and passing post-fix plus a clean broader-suite run. LGTM pending the tracking-issue note above.

@robfrank

robfrank commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Filed #5910 to track the sibling argument-validation paths (localdatetime(), localtime(), time(), remaining point() structural branches) called out as out-of-scope follow-up in the PR description and in the review above.

@claude

claude Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review

Reviewed the diff and cross-checked the core claim against AbstractServerHttpHandler (CommandSemanticException extends CommandParsingException, which is handled distinctly from the generic CommandExecutionException/500 path). The fix is correct and consistent with the existing pattern used for abs(), left()/right(), and the arithmetic-error paths.

Code quality

  • Minimal, surgical diff: only the exception class changes at the five call sites, messages untouched. No unnecessary refactoring.
  • RangeFunction.java: the now-unused CommandExecutionException import was correctly removed.
  • CypherPointFunction.java / DateConstructorFunction.java / DateTimeConstructorFunction.java: CommandExecutionException is still imported and used for other, intentionally out-of-scope branches (e.g. non-map point() argument, missing x/y, non-numeric srid, non-string/map/temporal date()/datetime() argument) - so those imports are correctly retained rather than removed.
  • Javadoc on CypherPointFunction and coerceCoordinate() was updated to reflect the new exception type, a nice touch for future maintainers.

Bugs

  • None found. Both coerceCoordinate() branches (non-numeric String, non-Number/non-String) are fixed together, which is right since they're the same validation guard.

Test coverage

  • CypherFunctionArgumentValidationIssue5794Test covers all 5 call sites plus a control test for valid inputs (validInputsStillSucceed), confirming the fix doesn't disturb the success path. Good TDD discipline per the PR description (reproduced against main first).
  • Minor nit: validInputsStillSucceed() uses fairly loose assertions (isNotNull(), .toString().contains(...)) rather than asserting exact parsed values - not a blocker, just could be tightened in a future pass.

Scope

Performance/Security

  • No concerns: this only changes which exception subclass is thrown on an already-failing path; no new allocations, loops, or attack surface.

Nothing blocking here - LGTM.

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.00%. Comparing base (6bbb0e7) to head (fcc6f20).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5909      +/-   ##
==========================================
- Coverage   68.39%   68.00%   -0.40%     
==========================================
  Files        1794     1794              
  Lines      152707   152710       +3     
  Branches    32366    32370       +4     
==========================================
- Hits       104450   103845     -605     
- Misses      34843    35487     +644     
+ Partials    13414    13378      -36     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robfrank
robfrank merged commit 456f670 into main Aug 7, 2026
27 of 31 checks passed
@robfrank
robfrank deleted the fix/5794-cypher-function-arg-validation-500 branch August 7, 2026 14:16
lvca added a commit that referenced this pull request Aug 7, 2026
…ks hidden (#5939)

#2378 removed database-level support for hidden properties in 2025, but left the
filter in Projection: for `SELECT *` it skipped any alias whose schema property
was marked hidden, while a bare `SELECT` returned the record's own names and
never filtered anything. The two spellings of "give me everything" have
disagreed ever since.

Nobody saw it because Projection also sets the element on the row, and
ResultInternal.getPropertyNames() used to union the element's names over the
content's, putting the filtered name straight back. #5613 stopped merging them
(to keep a Cypher `RETURN n` from emitting every type property as a null
column) and left the year-old filter exposed, which is what has had
CreatePropertyStatementExecutionTest.createHiddenProperty - and with it the
whole unit-tests job - red on main ever since.

Measured on ea4f6af before this change:

  SELECT * FROM Plain -> [name, extra, @Rid, @type]
  SELECT * FROM Hid   -> [extra, @Rid, @type]        <- hidden `name` dropped
  SELECT   FROM Hid   -> [name, extra]               <- hidden `name` returned

So the filter goes, finishing what #2378 started. `hidden` stays as a schema
annotation: ALTER PROPERTY still records it, AbstractProperty still exposes it,
and schema introspection still reports it - none of that is touched. Only the
read path stops honouring it. Hiding a property from a projection but not from
the record behind it was never a security boundary; it only made two queries
that should agree return different rows.

The inner `else if` branch goes with it: its only other condition was an
excludes check the line above already performs, so removing the hidden clause
left it dead. `!prop` exclusion syntax is unaffected and now has its own test.

Tests: createHiddenProperty passes as written for the first time since #5613.
hiddenPropertyIsReturnedByEverySpellingOfSelectAll pins `SELECT *` and bare
`SELECT` to the same answer and asserts the schema flag survives;
selectStarStillHonoursExplicitExclusions guards the loop simplification.
Mutation-checked by restoring the filter: both go red, the new one reporting
`got [plain, @Rid, @type]`. Full com.arcadedb.query.** sweep: 10598 tests, the
only failure is Issue4305Test.pointRaisesCleanErrorOnNonNumericString, which
fails identically on a clean ea4f6af checkout and comes from #5909 landing
after this branch's base.
lvca added a commit that referenced this pull request Aug 8, 2026
…mandSemanticException retyping (#5954)

RangeFunction.execute() and CypherPointFunction.coerceCoordinate() were
retyped from CommandExecutionException to CommandSemanticException by
PR #5909 (#5794) so the HTTP layer answers 400 on these errors. Two
pre-existing tests untouched by that PR, RangeFunctionTest.stepZeroIsStillRejected
and Issue4305Test.pointRaisesCleanErrorOnNonNumericString, still asserted the old
type and were deterministically failing on main.
tae898 pushed a commit to humemai/arcadedb-embedded-python that referenced this pull request Aug 23, 2026
… for incompatible temporal argument

The truncate functions (date.truncate(), time.truncate(), localtime.truncate(), datetime.truncate(),
localdatetime.truncate()) threw a bare CommandExecutionException when the second argument was not a
compatible temporal value (e.g. a TIME into date.truncate(), or a non-temporal value), which
AbstractServerHttpHandler maps to HTTP 500. The failure is determined entirely by the supplied
argument and cannot succeed on retry, so it is a client error: switched to CommandSemanticException
(HTTP 400), the same pattern already applied to the sibling constructor paths in ArcadeData#5909/ArcadeData#5910.

Also fixed CypherOptionalArgumentNullIssue5629Test, which asserted the old CommandExecutionException
as the (until now) known behavior for this exact defect.
oc007us pushed a commit to oc007us/arcadedb-grpc that referenced this pull request Aug 25, 2026
…rphic bucket cache; unchecked Number casts; Double.MIN_VALUE max seed

ArcadeData#6678: LocalDocumentType.cachedPolymorphicBuckets/cachedPolymorphicBucketIds are copy-on-write
reassigned under schema mutation but read lock-free on the query-planning hot path
(getBuckets(true)/getBucketIds(true)). Marked volatile so a planning thread has a happens-before
edge against a concurrent ALTER TYPE ... BUCKET, matching the LocalSchema.bucketId2TypeMap
publication pattern.

ArcadeData#6677: agg.nth, agg.slice, percentileCont, percentileDisc and vector_create cast a positional
argument to (Number) with no type check, so a non-numeric argument threw a raw
ClassCastException (HTTP 500) instead of a client type error. Routed through
CypherFunctionHelper.requireNumberArgument(), the mechanism ArcadeData#6609 introduced for
left/right/substring. RangeFunction, also named in the issue, already validates its arguments
(fixed by ArcadeData#5909 before this issue was filed) so it needed no change.

ArcadeData#6672: agg.statistics()/agg.maxItems() seeded their running maximum with Double.MIN_VALUE, the
smallest POSITIVE double, not the most-negative double. For any dataset whose true maximum is
<= 0 the seed was never beaten, so agg.statistics() reported a bogus tiny-positive max and
agg.maxItems() returned a bogus value with an empty items list. Seeded with
Double.NEGATIVE_INFINITY instead, matching the correct pattern already used by AggMinItems.
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.

range() with zero step, invalid date()/datetime() strings, and non-numeric point() coordinates return HTTP 500 instead of a client error

1 participant