kestra-io/kestra · error · CommandLine.ParameterException

Invalid key pair value for inputs

Error message

Invalid key pair value for inputs

What it means

Thrown by the 'kestra flow test' CLI command when the --inputs option receives an odd number of tokens. Inputs are parsed as key/value pairs (inputs[i], inputs[i+1]); if the count is not even (size <= i+1 fails), a picocli ParameterException is thrown. This is a usage error, not a runtime fault.

Source

Thrown at cli/src/main/java/io/kestra/cli/commands/flows/FlowTestCommand.java:93

    }

    @Override
    @SuppressWarnings("unchecked")
    public Integer call() throws Exception {
        super.call();

        LocalFlowRepositoryLoader repositoryLoader = applicationContext.getBean(LocalFlowRepositoryLoader.class);
        FlowRepositoryInterface flowRepository = applicationContext.getBean(FlowRepositoryInterface.class);
        ExecutionRepositoryInterface executionRepository = applicationContext.getBean(ExecutionRepositoryInterface.class);
        FlowInputOutput flowInputOutput = applicationContext.getBean(FlowInputOutput.class);
        TenantIdSelectorService tenantService = applicationContext.getBean(TenantIdSelectorService.class);
        DispatchQueueInterface<ExecutionCommand> executionCommandQueue = applicationContext.getBean(DispatchQueueInterface.class, Qualifiers.byTypeArguments(ExecutionCommand.class));

        Map<String, Object> inputs = new HashMap<>();

        for (int i = 0; i < this.inputs.size(); i = i + 2) {
            if (this.inputs.size() <= i + 1) {
                throw new CommandLine.ParameterException(this.spec.commandLine(), "Invalid key pair value for inputs");
            }

            inputs.put(this.inputs.get(i), this.inputs.get(i + 1));
        }

        try (StandAloneRunner runner = applicationContext.createBean(StandAloneRunner.class);) {
            runner.run();
            repositoryLoader.load(tenantService.getTenantId(tenantId), file.toFile());

            List<Flow> all = flowRepository.findAllForAllTenants();
            if (all.size() != 1) {
                throw new IllegalArgumentException("Too many flow found, need 1, found " + all.size());
            }

            var flow = all.getFirst();
            var createCommand = Create.of(flow.toFlowId()).withInputsFromReader((executionId) -> flowInputOutput.readExecutionInputs(flow, executionId, inputs));
            executionCommandQueue.emit(
                createCommand

View on GitHub (pinned to 823fada927)

Solutions

  1. Provide inputs as an even number of tokens: --inputs key1 value1 key2 value2.
  2. Quote any value containing spaces: --inputs greeting "hello world".
  3. Run 'kestra flow test --help' to confirm the expected key/value pairing syntax.

Example fix

# before (odd count)
kestra flow test myflow.yaml --inputs greeting hello name
# after (even count, quoted value)
kestra flow test myflow.yaml --inputs greeting "hello" name "world"
Defensive patterns

Strategy: validation

Validate before calling

if (inputs == null || inputs.size() % 2 != 0) {
  throw new IllegalArgumentException("--inputs must be an even number of key/value tokens");
}

Prevention

When it happens

Trigger: User runs 'flow test --inputs key1 value1 key2' (odd count); the loop detects inputs.size() <= i+1 before pairing and throws CommandLine.ParameterException.

Common situations: Typo dropping a value, copy-paste of a single value, a value containing a space that the shell split incorrectly, or forgetting to quote a value with spaces.

Related errors


AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14). Data as JSON: /api/errors/54217d8fb2d9825a. Report an issue: GitHub.