apache/pulsar · error · ParameterException

Either a trigger value or a trigger filepath needs to be spe

Error message

Either a trigger value or a trigger filepath needs to be specified

What it means

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.

Source

Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java:1144

        @Option(names = "--topic", description = "The specific topic name that the function consumes from that"
                + " you want to inject the data to")
        protected String topic;

        public void mergeArgs() {
            if (isBlank(triggerValue) && !isBlank(deprecatedTriggerValue)) {
                triggerValue = deprecatedTriggerValue;
            }
            if (isBlank(triggerFile) && !isBlank(deprecatedTriggerFile)) {
                triggerFile = deprecatedTriggerFile;
            }
        }

        @Override
        void runCmd() throws Exception {
            // merge deprecated args with new args
            mergeArgs();
            if (triggerFile == null && triggerValue == null) {
                throw new ParameterException("Either a trigger value or a trigger filepath needs to be specified");
            }
            String retval = getAdmin().functions()
                    .triggerFunction(tenant, namespace, functionName, topic, triggerValue, triggerFile);
            System.out.println(retval);
        }
    }

    @Command(description = "Upload File Data to Pulsar")
    class UploadFunction extends BaseCommand {
        // for backward compatibility purposes
        @Option(
                names = "--sourceFile",
                description = "The file whose contents need to be uploaded", hidden = true)
        protected String deprecatedSourceFile;
        @Option(
                names = "--source-file",
                description = "The file whose contents need to be uploaded")
        protected String sourceFile;

View on GitHub (pinned to 820761864e)

Solutions

  1. Pass either --trigger-value or --trigger-file

Example fix

// before
pulsar-admin functions trigger t n myfunc --topic in
// after
pulsar-admin functions trigger t n myfunc --topic in --trigger-value 'hello'
Defensive patterns

Strategy: validation

Validate before calling

if (triggerValue == null && triggerFile == null) {
    throw new IllegalArgumentException("Provide --trigger-value or --trigger-file");
}
if (triggerFile != null && !new File(triggerFile).exists()) {
    throw new IllegalArgumentException("trigger file does not exist: " + triggerFile);
}

Try / catch

try { admin.functions().triggerFunction(t, n, fn, topic, value, file); }
catch (ParameterException e) { if (e.getMessage().contains("trigger value or a trigger filepath")) { log.error("Supply --trigger-value or --trigger-file"); } throw e; }

Prevention

When it happens

Trigger: Running `pulsar-admin functions trigger <tenant> <namespace> <functionName>` with both --trigger-value and --trigger-file unset, checked in TriggerFunction.runCmd at CmdFunctions.java:1144.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/33661b4dcc4856d0. Report an issue: GitHub.