{"record":{"id":"3d76f258b1e5043a","repo":"apache/pulsar","slug":"unsupported-url-protocol","errorCode":null,"errorMessage":"Unsupported url protocol ","messagePattern":"Unsupported url protocol ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionCommon.java","lineNumber":268,"sourceCode":"    public static File createPkgTempFile() throws IOException {\n        return File.createTempFile(\"functions\", \".tmp\");\n    }\n\n    public static File extractFileFromPkgURL(String destPkgUrl) throws IOException, URISyntaxException {\n        if (destPkgUrl.startsWith(Utils.FILE)) {\n            URL url = new URL(destPkgUrl);\n            File file = new File(url.toURI());\n            if (!file.exists()) {\n                throw new IOException(destPkgUrl + \" does not exists locally\");\n            }\n            return file;\n        } else if (destPkgUrl.startsWith(\"http\")) {\n            File tempFile = createPkgTempFile();\n            tempFile.deleteOnExit();\n            downloadFromHttpUrl(destPkgUrl, tempFile);\n            return tempFile;\n        } else {\n            throw new IllegalArgumentException(\"Unsupported url protocol \"\n                    + destPkgUrl + \", supported url protocols: [file/http/https]\");\n        }\n    }\n\n    public static String getFullyQualifiedInstanceId(Instance instance) {\n        return getFullyQualifiedInstanceId(\n                instance.getFunctionMetaData().getFunctionDetails().getTenant(),\n                instance.getFunctionMetaData().getFunctionDetails().getNamespace(),\n                instance.getFunctionMetaData().getFunctionDetails().getName(),\n                instance.getInstanceId());\n    }\n\n    public static String getFullyQualifiedInstanceId(String tenant, String namespace,\n                                                     String functionName, int instanceId) {\n        return String.format(\"%s/%s/%s:%d\", tenant, namespace, functionName, instanceId);\n    }\n\n    public static final long getSequenceId(MessageId messageId) {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionCommon.java#L250-L286","documentation":"FunctionCommon.extractFileFromPkgURL only supports file://, http:// and https:// package URLs. Any other scheme (e.g. ftp://, s3://, function:// without support, or a malformed URL with no recognizable protocol) falls through to this IllegalArgumentException listing the supported protocols.","triggerScenarios":"Calling extractFileFromPkgURL with a destPkgUrl whose string neither starts with 'file' nor 'http' — e.g. using an ftp:// or s3:// URL, a bare path without a scheme like /path/to/app.jar, or a function://package-management URL passed to a code path that expects a downloadable URL.","commonSituations":"Pointing a function package at an object-store URI (s3://, gs://) the worker cannot download; forgetting the file:// prefix on a local path; scripting tools emitting relative paths; package management service URLs used where raw download URLs are required (older Pulsar versions).","solutions":["Prefix local paths with file:// and use http:// or https:// URLs for remote artifacts","Upload the artifact to an HTTP(S)-reachable repository and reference that URL","If using Pulsar package management, ensure the Pulsar version supports the function:// scheme in this code path, or download the package and pass a file:// URL","Check for typos/trailing whitespace in the configured pkgUrl"],"exampleFix":"// before\nnew CreateFunction().setPkgUrl(\"/opt/functions/app.jar\") // no scheme -> throws\n// after\nnew CreateFunction().setPkgUrl(\"file:///opt/functions/app.jar\");","handlingStrategy":"validation","validationCode":"// Pre-validate the package URL scheme\nString pkgUrl = \"file:///opt/functions/app.jar\";\nif (!(pkgUrl.startsWith(\"file\") || pkgUrl.startsWith(\"http\"))) {\n  throw new IllegalStateException(\"Unsupported pkgUrl scheme, use file:// or http(s)://: \" + pkgUrl);\n}","typeGuard":null,"tryCatchPattern":"try {\n  File f = FunctionCommon.extractFileFromPkgURL(pkgUrl);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unsupported url protocol\")) {\n    log.error(\"Fix pkgUrl scheme: {}\", e.getMessage());\n    pkgUrl = \"file://\" + pkgUrl; // e.g. missing scheme on local path\n  } else {\n    throw e;\n  }\n}","preventionTips":["Always include an explicit scheme: file:// for local, http(s):// for remote","Never pass bare paths, ftp://, or object-store URIs (s3://) to pkgUrl","Normalize/trim configured URLs before submission","Document supported schemes in your deployment tooling"],"tags":["pulsar-functions","url","package-url","validation"],"backgroundTag":"unsupported-url-protocol","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"}