Repository navigation
fix(#5794): range() zero step, invalid date()/datetime(), non-numeric point() coordinates return HTTP 400 - #5909
Conversation
… 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.
|
Tick the box to add this pull request to the merge queue (same as
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
🟢 Coverage 100.00% diff coverage · -6.84% coverage variation
Metric Results Coverage variation ✅ -6.84% coverage variation Diff coverage ✅ 100.00% diff coverage 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.
ReviewSmall, well-scoped fix. Verified the core claim against the current handler code: Code quality
Scope
Tests
Docs
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 |
|
Filed #5910 to track the sibling argument-validation paths ( |
ReviewReviewed the diff and cross-checked the core claim against Code quality
Bugs
Test coverage
Scope
Performance/Security
Nothing blocking here - LGTM. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
…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.
…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.
… 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.
…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.
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 stepdate()with a string that parses as neither a date nor a timezonedatetime()with a string that parses as neither a datetime nor a timezonepoint()with a non-numeric coordinate (both branches of the sharedcoerceCoordinate()guard: a non-numericStringand a value that is neither aNumbernor a numeric-lookingString)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 otherpoint()structural-validation branches (missingx/yorlongitude/latitude, non-map argument, non-numericsrid). Those are out of scope for this issue and are recommended as a follow-up.Test plan
engine/src/test/java/com/arcadedb/query/opencypher/CypherFunctionArgumentValidationIssue5794Test.javareproduces all four named paths (five call sites) and assertsCommandSemanticException, plus a valid-input control test.mainbefore the fix (assertingCommandExecutionExceptionwas thrown instead), proving the bug.mvn -pl engine -am test -Dtest=CypherFunctionArgumentValidationIssue5794Testpasses (6/6) after the fix.CypherNumericFunctionArgumentIssue5484Test,CypherFollowUpsIssue5602Test,CypherOptionalArgumentNullIssue5629Test,OpenCypherSpatialFunctionsComprehensiveTest,CypherFunctionFactoryExtendedTest,CypherFunctionArityRegistryTest.mvn -pl engine -am compilesucceeds.Checklist
mvn clean packagecommand