{"record":{"id":"10a278ecaa966419","repo":"apache/pulsar","slug":"s-package-does-not-have-the-correct-format-pulsa-10a278","errorCode":null,"errorMessage":"%s package does not have the correct format. Pulsar cannot determine if the package is a NAR package or JAR package. Attempts to load it as a NAR package produced error: ","messagePattern":"(.+?) package does not have the correct format\\. Pulsar cannot determine if the package is a NAR package or JAR package\\. Attempts to load it as a NAR package produced error: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionRuntimeCommon.java","lineNumber":157,"sourceCode":"                    }\n                } else {\n                    StringBuilder errorMsg = new StringBuilder(FunctionCommon.capFirstLetter(componentType)\n                            + \" package does not have the correct format.\"\n                            + \" Pulsar cannot determine if the package is a NAR package or JAR package.\");\n\n                    if (jarClassLoaderException != null) {\n                        errorMsg.append(\n                                \" Attempts to load it as a JAR package produced error: \" + jarClassLoaderException\n                                        .getMessage());\n                    }\n\n                    if (narClassLoaderException != null) {\n                        errorMsg.append(\n                                \" Attempts to load it as a NAR package produced error: \" + narClassLoaderException\n                                        .getMessage());\n                    }\n\n                    throw new IllegalArgumentException(errorMsg.toString());\n                }\n            }\n        } finally {\n            if (!keepJarClassLoader) {\n                ClassLoaderUtils.closeClassLoader(jarClassLoader);\n            }\n            if (!keepNarClassLoader) {\n                ClassLoaderUtils.closeClassLoader(narClassLoader);\n            }\n        }\n    }\n\n}\n","sourceCodeStart":139,"sourceCodeEnd":171,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionRuntimeCommon.java#L139-L171","documentation":"When a connector class name is provided but the archive could not be loaded as either a JAR or a NAR, getClassLoaderFromPackage builds this message explaining Pulsar cannot determine the package format, appending any NAR-loading error message.","triggerScenarios":"Registering a source/sink with an explicit class name where both jar creation and NAR creation of the archive failed (e.g. invalid ZIP structure, missing NAR manifest, corrupt upload).","commonSituations":"Uploaded a wrong file (e.g. a tar.gz, a pom.xml, an HTML error page saved as .jar); truncated download; NAR missing the required manifest/structure while also being unloadable as a plain jar.","solutions":["Run 'file my-archive.jar' and 'unzip -t my-archive.jar' to confirm it is a valid ZIP/JAR","Re-download/re-upload the archive — a truncated transfer is the most common cause","If it should be a NAR, verify it has the correct structure (META-INF/MANIFEST.MF, shaded dependencies)","Read the appended 'error: ...' text in the message — it names the actual NAR loading problem"],"exampleFix":"// before\ncurl -o connector.nar https://mirror/connector.nar  # interrupted download\n// after\ncurl -fSL -o connector.nar https://mirror/connector.nar && unzip -t connector.nar","handlingStrategy":"validation","validationCode":"// check the archive is a valid ZIP before submitting\ntry (ZipFile zf = new ZipFile(archive.toFile())) {\n  if (zf.getEntry(\"META-INF/MANIFEST.MF\") == null) {\n    throw new IllegalStateException(\"Not a valid JAR/NAR: missing manifest\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  createFunction(...);\n} catch (IllegalArgumentException e) {\n  // message includes the NAR-loading error after \"produced error: \"\n  log.error(\"Archive format invalid: {}\", e.getMessage());\n}","preventionTips":["Verify integrity after download (checksum or 'unzip -t')","Ensure the correct file is uploaded (a real JAR/NAR, not a redirect page or tarball)","Build NARs with the official pulsar NAR layout so both JAR and NAR loading paths behave predictably"],"tags":["pulsar-functions","nar-archive","jar","archive-format"],"backgroundTag":"invalid-archive-format","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}