{"record":{"id":"2b600afe6d16f083","repo":"apache/pulsar","slug":"invalid-format-for-fully-qualified-instance-name","errorCode":null,"errorMessage":"Invalid format for fully qualified instance name: ","messagePattern":"Invalid format for fully qualified instance name: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionInstanceId.java","lineNumber":35,"sourceCode":" * under the License.\n */\npackage org.apache.pulsar.functions.utils;\n\nimport lombok.Data;\n\n@Data\npublic class FunctionInstanceId {\n\n    private String tenant;\n    private String namespace;\n    private String name;\n    private int instanceId;\n\n    public FunctionInstanceId(String fullyQualifiedInstanceName) {\n        String[] t1 = fullyQualifiedInstanceName.split(\"/\");\n\n        if (t1.length != 3) {\n            throw new IllegalArgumentException(\n                    \"Invalid format for fully qualified instance name: \" + fullyQualifiedInstanceName);\n        }\n\n        this.tenant = t1[0];\n        this.namespace = t1[1];\n\n        int instanceIdDelimiterIndex = t1[2].lastIndexOf(':');\n\n        if (instanceIdDelimiterIndex < 0) {\n            throw new IllegalArgumentException(\n                    \"Invalid format for fully qualified instance name: \" + fullyQualifiedInstanceName);\n        }\n\n        this.name = t1[2].substring(0, instanceIdDelimiterIndex);\n        this.instanceId = Integer.parseInt(t1[2].substring(instanceIdDelimiterIndex + 1));\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionInstanceId.java#L17-L53","documentation":"FunctionInstanceId parses a fully qualified instance name expected to be 'tenant/namespace/name:instanceId'. The constructor splits on '/' and throws IllegalArgumentException if the string does not contain exactly 3 slash-separated parts.","triggerScenarios":"Calling new FunctionInstanceId(String) with a name missing '/' separators (e.g. only 'tenant/namespace' or a bare function name) or containing extra '/' segments (e.g. full topic-style names).","commonSituations":"Passing a function name instead of an instance name; passing a Pulsar topic or FQFN without the ':instanceId' suffix; copying names from logs that trimmed parts.","solutions":["Pass the complete 'tenant/namespace/functionName:instanceId' string.","Derive the instance name from FunctionInstanceId's formatting methods instead of hand-building the string.","Pre-validate with a regex like ^[^/]+/[^/]+/[^/]+:\\d+$ before constructing.","Check the caller for string truncation or use of the wrong identifier (function vs instance)."],"exampleFix":"// before\nnew FunctionInstanceId(\"tenant/ns/myfunc\"); // missing :instanceId\n// after\nnew FunctionInstanceId(\"tenant/ns/myfunc:0\");","handlingStrategy":"validation","validationCode":"java.util.regex.Pattern P = java.util.regex.Pattern.compile(\"[^/]+/[^/]+/[^/]+\\\\:\\\\d+\");\nif (fullyQualifiedInstanceName == null || !P.matcher(fullyQualifiedInstanceName).matches()) {\n    throw new IllegalArgumentException(\"Expected tenant/namespace/name:instanceId, got: \" + fullyQualifiedInstanceName);\n}","typeGuard":"static boolean isFullyQualifiedInstanceName(String s) {\n    return s != null && s.matches(\"[^/]+/[^/]+/[^/]+:\\\\d+\");\n}","tryCatchPattern":"try {\n    FunctionInstanceId id = new FunctionInstanceId(name);\n} catch (IllegalArgumentException e) {\n    log.error(\"Bad instance name '{}': expected tenant/namespace/name:instanceId\", name);\n}","preventionTips":["Always build instance names as tenant/namespace/name:instanceId.","Don't pass function names, FQFNs, or topic names where an instance name is expected.","Validate with a regex before constructing.","Use the class's own formatting output rather than string concatenation."],"tags":["pulsar-functions","parsing","illegal-argument"],"backgroundTag":"invalid-instance-name-format","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"}