Skip to content

[Cypher] Procedure.validateArgs() still reports a wrong argument count differently from functions #5627

Closed

Description

@lvca

Follow-up from #5602 (PR #5612), which unified the function side and deliberately left the procedure side alone.

Function.validateArgs() now delegates to Function.checkArity(), so a wrong argument count raises CommandSemanticException with the one canonical message (Function 'x' expects N arguments but got M) and reports as HTTP 400 whether it was caught while parsing or while running.

Procedure declares a separate validateArgs() of its own (engine/.../function/procedure/Procedure.java:109) that still throws IllegalArgumentException with the older wording (x() requires exactly N argument(s), got M). Around eighty procedures call it - every Algo*, Path*, Merge*, Db* - and CallStep.executeProcedure invokes it on the CALL path.

So the same mistake reads two different ways depending on whether the name resolves to a function or a procedure:

CALL text.hammingDistance('a')   -> Function 'text.hammingDistance' expects 2 arguments but got 1   (400)
CALL algo.dijkstra(...)          -> algo.dijkstra() requires exactly N argument(s), got M            (wrapped)

It was left out of #5602 on purpose: procedures are a different abstraction with their own registry and their own CALL handling, so unifying them is a change to that abstraction rather than to the function one, and #5602 was already large. The reason is recorded on Function.validateArgs.

Suggested fix. Give Procedure the same treatment - a checkArity reading its declared getMinArgs()/getMaxArgs(), phrased through the shared FunctionArity so procedures and functions describe an argument-count mistake identically. Worth checking at the same time whether the ~80 hand-written validateArgs(args) calls at the top of each execute() can then be dropped in favour of the guard the base interface already runs.

Note CallStep.executeProcedure catches Exception and wraps; since #5612 it rethrows CommandParsingException untouched, so once Procedure raises a client error it will propagate with the right status automatically.

Activity

  1. self-assigned this
    on Aug 1, 2026
  2. added a commit that references this issue on Aug 1, 2026
  3. added this to the 26.8.1 milestone on Aug 1, 2026
  4. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions