Skip to content

Bad function name some time #116

Open

Description

@sergeevik

If custom jsonata function is lambda then name is useless (com.dashjoin.jsonata.Jsonata$$Lambda/0x00000217108ce4d8)

Image

and some other place similar behavior:

all function methods ignore name parameter:

    public static<A,B,R> JFunction function(String name, Fn1<A,R> func, String signature) {
        return new JFunction(func.getJFunctionCallable(), signature);
    }

it is bad because in log i get useless error:

com.dashjoin.jsonata.JException: Argument "1" of Object "com.dashjoin.jsonata.Jsonata$$Lambda/0x00000217108ce4d8" does not match Object signature
	at com.dashjoin.jsonata.utils.Signature.throwValidationError(Signature.java:289) ~[jsonata-0.9.9.jar:na]

in example it was Signature. When create JFuntion with signature. name of function ignored for Signature

        public JFunction(String functionName, JFunctionCallable function, String signature, int numberOfArgs) {
            this.functionName = functionName;
            this.function = function;
            this.numberOfArgs = numberOfArgs;
            if (signature!=null)
                // use classname as default, gets overwritten once the function is registered
                this.signature = new Signature(signature, function.getClass().getName()); <-- class name maybe lambda
        }

Activity

  1. aeberhart commented on Jul 7, 2026

    @aeberhart
    Contributor

    I tested this example:

        var expression = Jsonata.jsonata("$test('x')");
        expression.registerFunction("test", Jsonata.function("x", (Fn1<String, String>)((x)->x), "a"));
    

    This yields this exception:

    com.dashjoin.jsonata.JException: Argument "1" of Object "test" does not match Object signature
    	at com.dashjoin.jsonata/com.dashjoin.jsonata.utils.Signature.throwValidationError(Signature.java:295)
    	at com.dashjoin.jsonata/com.dashjoin.jsonata.utils.Signature.validate(Signature.java:398)
    

    You are right that the "name" parameter (in this case 'x') is not used, but other than that, I do not see what the issue is. Am I missing something?

  2. sergeevik commented on Jul 7, 2026

    @sergeevik
    ContributorAuthor

    @aeberhart check mr #117

    i catch this exception message in "transform" operation.
    It creates an anonymous function without a name, making it difficult to debug what went wrong.
    I also added name forwarding in the function creation methods, and when creating a JFunction signature, the function name is concatenated with the class name (adding new behavior without removing the old one).

    Also, users can create named functions without registering them, for example when one function returns another

  3. aeberhart commented on Jul 7, 2026

    @aeberhart
    Contributor

    ok - got it

        var expression = Jsonata.jsonata("$ ~> |$|{}|");
        expression.evaluate(123);
    

    causes

    com.dashjoin.jsonata.JException: Argument "1" of Object "com.dashjoin.jsonata.Jsonata$$Lambda/0x00003fe00019fba0" does not match Object signature
    	at com.dashjoin.jsonata/com.dashjoin.jsonata.utils.Signature.throwValidationError(Signature.java:289)
    	at com.dashjoin.jsonata/com.dashjoin.jsonata.utils.Signature.validate(Signature.java:398)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions