{"record":{"id":"7f840d91b3dfbc7b","repo":"apache/pulsar","slug":"source-file-needs-to-be-specified","errorCode":null,"errorMessage":"--source-file needs to be specified","messagePattern":"--source-file 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":1179,"sourceCode":"                description = \"The file whose contents need to be uploaded\")\n        protected String sourceFile;\n        @Option(\n                names = \"--path\",\n                description = \"Path or functionPkgUrl where the contents need to be stored\", required = true)\n        protected String path;\n\n        private void mergeArgs() {\n            if (isBlank(sourceFile) && !isBlank(deprecatedSourceFile)) {\n                sourceFile = deprecatedSourceFile;\n            }\n        }\n\n        @Override\n        void runCmd() throws Exception {\n            // merge deprecated args with new args\n            mergeArgs();\n            if (StringUtils.isBlank(sourceFile)) {\n                throw new ParameterException(\"--source-file needs to be specified\");\n            }\n            getAdmin().functions().uploadFunction(sourceFile, path);\n            print(\"Uploaded successfully\");\n        }\n    }\n\n    @Command(description = \"Download File Data from Pulsar\")\n    class DownloadFunction extends FunctionCommand {\n        // for backward compatibility purposes\n        @Option(\n                names = \"--destinationFile\",\n                description = \"The file to store downloaded content\", hidden = true)\n        protected String deprecatedDestinationFile;\n        @Option(\n                names = \"--destination-file\",\n                description = \"The file to store downloaded content\")\n        protected String destinationFile;\n        @Option(","sourceCodeStart":1161,"sourceCodeEnd":1197,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java#L1161-L1197","documentation":"Thrown by the `functions upload` subcommand when --source-file is blank. Uploading a function artifact to Pulsar's package management requires a local source file to send to the service via functions().uploadFunction.","triggerScenarios":"Running `pulsar-admin functions upload --path <destination>` without --source-file (or with an empty value), checked at CmdFunctions.java:1179.","commonSituations":"Uploading to a package path but forgetting the local artifact flag; script variable pointing at the artifact was empty; confusing upload with download argument names (--source-file is upload-only).","solutions":["Add --source-file <localArtifactPath> pointing at the jar/py/binary to upload","Verify the artifact path variable is non-empty in scripts","Keep --path (the remote destination) together with --source-file"],"exampleFix":"// before\npulsar-admin functions upload --path myfunc/myfunc.jar\n// after\npulsar-admin functions upload --source-file ./target/myfunc.jar --path myfunc/myfunc.jar","handlingStrategy":"validation","validationCode":"if (sourceFile == null || sourceFile.isBlank()) {\n    throw new IllegalArgumentException(\"--source-file is required for functions upload\");\n}\nif (!new File(sourceFile).exists()) {\n    throw new IllegalArgumentException(\"source file does not exist: \" + sourceFile);\n}","typeGuard":null,"tryCatchPattern":"try { admin.functions().uploadFunction(sourceFile, path); }\ncatch (ParameterException e) { if (e.getMessage().contains(\"--source-file\")) { log.error(\"Provide --source-file <local artifact>\"); } throw e; }","preventionTips":["Always pair --source-file (local) with --path (remote destination)","Verify artifact build produced the file before upload in CI"],"tags":["cli","validation","upload","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"}