{"record":{"id":"33661b4dcc4856d0","repo":"apache/pulsar","slug":"either-a-trigger-value-or-a-trigger-filepath-needs","errorCode":null,"errorMessage":"Either a trigger value or a trigger filepath needs to be specified","messagePattern":"Either a trigger value or a trigger filepath needs to be specified","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java","lineNumber":1144,"sourceCode":"        @Option(names = \"--topic\", description = \"The specific topic name that the function consumes from that\"\n                + \" you want to inject the data to\")\n        protected String topic;\n\n        public void mergeArgs() {\n            if (isBlank(triggerValue) && !isBlank(deprecatedTriggerValue)) {\n                triggerValue = deprecatedTriggerValue;\n            }\n            if (isBlank(triggerFile) && !isBlank(deprecatedTriggerFile)) {\n                triggerFile = deprecatedTriggerFile;\n            }\n        }\n\n        @Override\n        void runCmd() throws Exception {\n            // merge deprecated args with new args\n            mergeArgs();\n            if (triggerFile == null && triggerValue == null) {\n                throw new ParameterException(\"Either a trigger value or a trigger filepath needs to be specified\");\n            }\n            String retval = getAdmin().functions()\n                    .triggerFunction(tenant, namespace, functionName, topic, triggerValue, triggerFile);\n            System.out.println(retval);\n        }\n    }\n\n    @Command(description = \"Upload File Data to Pulsar\")\n    class UploadFunction extends BaseCommand {\n        // for backward compatibility purposes\n        @Option(\n                names = \"--sourceFile\",\n                description = \"The file whose contents need to be uploaded\", hidden = true)\n        protected String deprecatedSourceFile;\n        @Option(\n                names = \"--source-file\",\n                description = \"The file whose contents need to be uploaded\")\n        protected String sourceFile;","sourceCodeStart":1126,"sourceCodeEnd":1162,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java#L1126-L1162","documentation":"CmdFunctions trigger command requires exactly one input source: neither --trigger-value nor --trigger-file (nor their deprecated aliases) was supplied, so there is no data to inject into the function.","triggerScenarios":"Running `pulsar-admin functions trigger <tenant> <namespace> <functionName>` with both --trigger-value and --trigger-file unset, checked in TriggerFunction.runCmd at CmdFunctions.java:1144.","commonSituations":"Testing a function interactively and forgetting the payload flag; shell variable holding the payload was empty so the flag ended up blank; copying a command that piped the payload via file but the file flag was removed.","solutions":["Pass either --trigger-value or --trigger-file"],"exampleFix":"// before\npulsar-admin functions trigger t n myfunc --topic in\n// after\npulsar-admin functions trigger t n myfunc --topic in --trigger-value 'hello'","handlingStrategy":"validation","validationCode":"if (triggerValue == null && triggerFile == null) {\n    throw new IllegalArgumentException(\"Provide --trigger-value or --trigger-file\");\n}\nif (triggerFile != null && !new File(triggerFile).exists()) {\n    throw new IllegalArgumentException(\"trigger file does not exist: \" + triggerFile);\n}","typeGuard":null,"tryCatchPattern":"try { admin.functions().triggerFunction(t, n, fn, topic, value, file); }\ncatch (ParameterException e) { if (e.getMessage().contains(\"trigger value or a trigger filepath\")) { log.error(\"Supply --trigger-value or --trigger-file\"); } throw e; }","preventionTips":["Always pass a payload when triggering; guard payload variables in scripts for emptiness","Use --trigger-file for large or escaped payloads instead of inline strings"],"tags":["cli","validation","trigger","pulsar-functions"],"backgroundTag":"missing-required-argument","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}