{"record":{"id":"bc6c7e4bc8f7dcdc","repo":"apache/pulsar","slug":"cannot-specify-both-jar-and-function-type","errorCode":null,"errorMessage":"Cannot specify both jar and function-type","messagePattern":"Cannot specify both jar and function-type","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java","lineNumber":659,"sourceCode":"                }\n                windowConfig.setSlidingIntervalDurationMs(slidingIntervalDurationMs);\n            }\n\n            functionConfig.setWindowConfig(windowConfig);\n\n            if (autoAck != null) {\n                functionConfig.setAutoAck(autoAck);\n            }\n\n            if (null != maxMessageRetries) {\n                functionConfig.setMaxMessageRetries(maxMessageRetries);\n            }\n            if (null != deadLetterTopic) {\n                functionConfig.setDeadLetterTopic(deadLetterTopic);\n            }\n\n            if (jarFile != null && functionType != null) {\n                throw new ParameterException(\"Cannot specify both jar and function-type\");\n            }\n\n            if (null != jarFile) {\n                functionConfig.setJar(jarFile);\n            }\n\n            if (functionType != null) {\n                functionConfig.setJar(\"builtin://\" + functionType);\n            } else if (functionConfig.getFunctionType() != null) {\n                functionConfig.setJar(\"builtin://\" + functionConfig.getFunctionType());\n            }\n\n            if (null != pyFile) {\n                functionConfig.setPy(pyFile);\n            }\n\n            if (null != goFile) {\n                functionConfig.setGo(goFile);","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java#L641-L677","documentation":"A function can be packaged either as a user-uploaded jar or as a built-in function type (built-in connectors/functions identified by function-type). FunctionDetailsCommand rejects a command specifying both jarFile and functionType with a ParameterException, since the runtime cannot decide between the two packaging modes.","triggerScenarios":"Running functions create/update with both --jar (or --py/--go plus jar semantics) and --function-type / --builtin set at the same time.","commonSituations":"Template scripts that always pass --jar, then get extended with --function-type for built-ins; defaults baked into wrapper scripts where the jar variable is set to a non-null default.","solutions":["Remove --function-type if you are deploying your own jar.","Remove --jar (and class name requirements) if you intend to use a built-in function type.","Make wrapper scripts set exactly one of the two based on the deployment mode."],"exampleFix":"// before\npulsar-admin functions create --tenant public --namespace default --name ex --jar my.jar --function-type org.apache.pulsar.functions.api.examples.ExclamationFunction\n// after\npulsar-admin functions create --tenant public --namespace default --name ex --jar my.jar --classname org.ex.MyFn","handlingStrategy":"validation","validationCode":"if (jarFile != null && functionType != null) {\n    throw new IllegalArgumentException(\"Specify either --jar or --function-type, not both\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    functionsCmd.run();\n} catch (ParameterException e) {\n    if (e.getMessage().contains(\"jar and function-type\")) {\n        System.err.println(\"Choose one packaging mode: uploaded jar or built-in function-type.\");\n    }\n}","preventionTips":["In deploy scripts, branch explicitly: user-jar mode sets only --jar; builtin mode sets only --function-type.","Initialize jar variables to null, not to a default jar path, in wrappers.","Document the packaging choice per function so operators don't mix flags."],"tags":["cli","functions","argument-conflict","pulsar-functions"],"backgroundTag":"mutually-exclusive-arguments","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"}