{"record":{"id":"449f060ea4779c10","repo":"apache/pulsar","slug":"invalid-short-topic-name-s-it-should-be-in-the","errorCode":null,"errorMessage":"Invalid short topic name '%s', it should be in the format of <tenant>/<namespace>/<topic> or <topic>","messagePattern":"Invalid short topic name '(.+?)', it should be in the format of <tenant>/<namespace>/<topic> or <topic>","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pulsar-function-go/pf/topicName.go","lineNumber":58,"sourceCode":"\tpartitionedTopicSuffix = \"-partition-\"\n)\n\n// ParseTopicName parse the given topic name and return TopicName.\nfunc ParseTopicName(topic string) (*TopicName, error) {\n\t// The topic name can be in two different forms, one is fully qualified topic name,\n\t// the other one is short topic name\n\tif !strings.Contains(topic, \"://\") {\n\t\t// The short topic name can be:\n\t\t// - <topic>\n\t\t// - <tenant>/<namespace>/<topic>\n\t\t// - <tenant>/<cluster>/<namespace>/<topic>\n\t\tparts := strings.Split(topic, \"/\")\n\t\tif len(parts) == 3 || len(parts) == 4 {\n\t\t\ttopic = \"persistent://\" + topic\n\t\t} else if len(parts) == 1 {\n\t\t\ttopic = \"persistent://\" + publicTenant + \"/\" + defaultNamespace + \"/\" + parts[0]\n\t\t} else {\n\t\t\treturn nil, errors.New(\n\t\t\t\t\"Invalid short topic name '\" + topic +\n\t\t\t\t\t\"', it should be in the format of <tenant>/<namespace>/<topic> or <topic>\")\n\t\t}\n\t}\n\n\ttn := &TopicName{}\n\n\t// The fully qualified topic name can be in two different forms:\n\t// new:    persistent://tenant/namespace/topic\n\t// legacy: persistent://tenant/cluster/namespace/topic\n\tparts := strings.SplitN(topic, \"://\", 2)\n\tdomain := parts[0]\n\tif domain != \"persistent\" && domain != \"non-persistent\" {\n\t\treturn nil, errors.New(\"Invalid topic domain: \" + domain)\n\t}\n\ttn.Domain = domain\n\n\trest := parts[1]","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-function-go/pf/topicName.go#L40-L76","documentation":"ParseTopicName accepts either a fully qualified topic (persistent://tenant/namespace/topic) or a short topic name (<topic>) which is expanded using the default tenant/namespace. A name with 2 slash-separated segments (e.g. myns/mytopic) fits neither form, so parsing fails with this error.","triggerScenarios":"Passing a topic like 'public/mytopic' or 'tenant/topic' (2 segments) to setupConsumer or respondMessage; only 1, 3, or 4 segments are valid.","commonSituations":"Developers supplying tenant/namespace fragments partially, splitting config strings incorrectly, or copying topic names from UI columns that omit the domain prefix.","solutions":["Use the full short form: just the topic name, e.g. 'mytopic'","Or use the fully qualified form: 'persistent://public/default/mytopic'","Check the string for stray or missing slashes; 2 segments is always invalid","In Java-interop configs use 'persistent://public/default/<topic>'"],"exampleFix":"// before\npf.ParseTopicName(\"public/mytopic\") // error\n// after\npf.ParseTopicName(\"persistent://public/default/mytopic\")","handlingStrategy":"validation","validationCode":"segments := strings.Count(topic, \"/\") + 1\nif segments != 1 && segments != 3 && segments != 4 {\n    return fmt.Errorf(\"topic %q must have 1, 3, or 4 slash-separated segments\", topic)\n}","typeGuard":"func isShortTopic(t string) bool { return !strings.Contains(t, \"://\") && strings.Count(t, \"/\") == 0 }","tryCatchPattern":"tn, err := pf.ParseTopicName(topic)\nif err != nil {\n    return fmt.Errorf(\"parse topic %q: %w\", topic, err)\n}","preventionTips":["Prefer fully qualified persistent://tenant/namespace/topic names in configs","Never pass tenant/namespace fragments (2 segments)","Strip surrounding whitespace before parsing"],"tags":["go","topic-name","validation","pulsar-functions"],"backgroundTag":"invalid-topic-name","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"}