{"record":{"id":"b7477ef864f12e94","repo":"kestra-io/kestra","slug":"too-many-flow-found-need-1-found","errorCode":null,"errorMessage":"Too many flow found, need 1, found {}","messagePattern":"Too many flow found, need 1, found (.+?)","errorType":"console","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"cli/src/main/java/io/kestra/cli/commands/flows/FlowTestCommand.java","lineNumber":105,"sourceCode":"        DispatchQueueInterface<ExecutionCommand> executionCommandQueue = applicationContext.getBean(DispatchQueueInterface.class, Qualifiers.byTypeArguments(ExecutionCommand.class));\n\n        Map<String, Object> inputs = new HashMap<>();\n\n        for (int i = 0; i < this.inputs.size(); i = i + 2) {\n            if (this.inputs.size() <= i + 1) {\n                throw new CommandLine.ParameterException(this.spec.commandLine(), \"Invalid key pair value for inputs\");\n            }\n\n            inputs.put(this.inputs.get(i), this.inputs.get(i + 1));\n        }\n\n        try (StandAloneRunner runner = applicationContext.createBean(StandAloneRunner.class);) {\n            runner.run();\n            repositoryLoader.load(tenantService.getTenantId(tenantId), file.toFile());\n\n            List<Flow> all = flowRepository.findAllForAllTenants();\n            if (all.size() != 1) {\n                throw new IllegalArgumentException(\"Too many flow found, need 1, found \" + all.size());\n            }\n\n            var flow = all.getFirst();\n            var createCommand = Create.of(flow.toFlowId()).withInputsFromReader((executionId) -> flowInputOutput.readExecutionInputs(flow, executionId, inputs));\n            executionCommandQueue.emit(\n                createCommand\n            );\n            Execution terminated = await().atMost(Duration.ofHours(1)).until(\n                () -> executionRepository.findById(tenantService.getTenantId(tenantId), createCommand.executionId()).orElse(null),\n                e -> e != null && e.getState().isTerminated()\n            );\n            stdOut(\"Successfully executed the flow with execution %s in state %s\", terminated.getId(), terminated.getState().getCurrent());\n        } catch (ConstraintViolationException e) {\n            throw new CommandLine.ParameterException(this.spec.commandLine(), e.getMessage());\n        } catch (IOException e) {\n            throw new IllegalStateException(e);\n        } finally {\n            applicationContext.getProperty(\"kestra.storage.local.base-path\", Path.class)","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/cli/src/main/java/io/kestra/cli/commands/flows/FlowTestCommand.java#L87-L123","documentation":"Thrown by 'kestra flow test' when the loader finds more than one flow from the provided file/path. The command is designed to test exactly one flow; after repositoryLoader.load and flowRepository.findAllForAllTenants(), if the result size is not 1 it throws IllegalArgumentException naming the count found. This usually means the path is a directory containing multiple flow files.","triggerScenarios":"repositoryLoader.load(tenantId, file) loads multiple flows (e.g. a directory or a multi-doc YAML), findAllForAllTenants().size() != 1, and IllegalArgumentException is thrown with the actual count.","commonSituations":"User passes a directory instead of a single flow file, a YAML file contains multiple flow documents, the path glob expanded to several files, or pre-existing flows in the repository are counted alongside the new one.","solutions":["Point --file at a single flow YAML file, not a directory.","Ensure the YAML contains exactly one flow definition (no multi-document separators).","If testing in a populated repo, scope by tenant/namespace or run against an empty repository.","Use a dedicated test workspace containing only the target flow."],"exampleFix":"# before: directory with several flows\nkestra flow test ./flows/\n# after: single file\nkestra flow test ./flows/myflow.yaml","handlingStrategy":"validation","validationCode":"List<Flow> all = flowRepository.findAllForAllTenants();\nif (all.size() != 1) {\n  throw new IllegalStateException('Expected exactly one flow, found ' + all.size());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point --file at a single flow file, not a directory.","Use a clean test workspace so pre-existing flows are not counted.","Avoid multi-document YAML for flow-test."],"tags":["cli","flow-test","usage","argument-parsing"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}