You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Cypher] Procedure.validateArgs() still reports a wrong argument count differently from functions #5627
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 separatevalidateArgs() 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
fix(engine) #5627: report a procedure's wrong argument count the way …
fix(engine) #5627: report a procedure's wrong argument count the way …