Skip to content

Fix HTTP Action API &return= crashing (ArrayIndexOutOfBoundsException) for a property with parameters #1688

@CrushBy

Description

@CrushBy

Description

Follow-up to #1687. After that fix a single return=<property> query
parameter works for a 0-arity property, but still fails with an
HTTP 500 (internal ArrayIndexOutOfBoundsException) when the named
property takes one or more parameters. The property is read with no
arguments and the read path indexes into an empty argument array instead
of either reading it with NULL arguments or reporting a clear error.

The rule is purely arity-based — 0-arity returns the value, anything with
parameters crashes:

# 0-arity property -> 200, value in the body
POST /eval/action?return=currentUser        -> 200   body: 215

# property with parameters -> HTTP 500 (ArrayIndexOutOfBoundsException)
POST /eval/action?return=idTask             -> 500   # idTask(Task)
POST /eval/action?return=responsible        -> 500   # responsible(Task)

(devmode, no Authorization header; the script body is a harmless
no-op such as MESSAGE 'x';. Reproduced on both /eval and
/eval/action, query-string return= only — a return field in a POST
body is ignored, per #1687. Any property declared with parameters
reproduces it, including built-in ones.)

Expected

Read the property with NULL/empty arguments and return that, or fail
with a clear, actionable error — the way the neighbouring cases already
do — instead of an opaque ArrayIndexOutOfBoundsException:

return=                  -> CompoundNameUtils$ParseException: name '' contains forbidden symbols
return=doesNotExist      -> RuntimeException: Return property doesNotExist was not found
return=name (overloaded) -> AmbiguousElementException: Ambiguous element 'name' was found in modules: ...

Stack trace

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at lsfusion.server.language.property.oraction.LAP.lambda$0(LAP.java:45)
    at lsfusion.base.col.implementations.simple.SingletonSet.mapOrderValues(SingletonSet.java:330)
    at lsfusion.server.language.property.oraction.LAP.getMap(LAP.java:45)
    at lsfusion.server.language.property.oraction.LAP.getMapValues(LAP.java:37)
    at lsfusion.server.language.property.LP.read(LP.java:98)
    at lsfusion.server.language.property.LP.read(LP.java:110)
    at lsfusion.server.physics.admin.authentication.controller.remote.RemoteConnection.readResult(RemoteConnection.java:744)
    at lsfusion.server.physics.admin.authentication.controller.remote.RemoteConnection.executeExternal(RemoteConnection.java:588)

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    APIAPIbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions