{"record":{"id":"fb0f6a25c2491a06","repo":"apache/beam","slug":"xlangx-registerhandler-v","errorCode":null,"errorMessage":"xlangx.RegisterHandler: %v","messagePattern":"xlangx\\.RegisterHandler: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/xlangx/registry.go","lineNumber":174,"sourceCode":"\tmu           sync.Mutex\n\thandlers     map[string]HandlerFunc // namespace -> handlerfuncs\n\turnOverrides map[string]string      // URNs -> expansionAddrs\n}\n\nfunc newRegistry() *registry {\n\treturn &registry{\n\t\thandlers:     map[string]HandlerFunc{},\n\t\turnOverrides: map[string]string{},\n\t}\n}\n\n// RegisterHandler associates a namespace, with a handler.\n//\n// Namespaces may not have the configuration separator \":\" in them,\n// nor may they be a restricted namespace, like \"localhost\" or \"http\".\nfunc (r *registry) RegisterHandler(namespace string, handler HandlerFunc) error {\n\tif err := validateNamespace(namespace); err != nil {\n\t\treturn fmt.Errorf(\"xlangx.RegisterHandler: %v\", err)\n\t}\n\tr.mu.Lock()\n\tdefer r.mu.Unlock()\n\tr.handlers[namespace] = handler\n\treturn nil\n}\n\nfunc validateNamespace(namespace string) error {\n\tif strings.Contains(namespace, Separator) {\n\t\treturn fmt.Errorf(\"invalid namespace, provide a different one: %q contains the separator %q\", namespace, Separator)\n\t}\n\tif _, ok := restricted[namespace]; ok {\n\t\treturn fmt.Errorf(\"invalide namespace, provide a different one: %q is a restricted namespace\", namespace)\n\t}\n\treturn nil\n}\n\n// RegisterOverrideForUrn instructs using expansionAddr for CrossLanguage","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/xlangx/registry.go#L156-L192","documentation":"registry.RegisterHandler associates an expansion-request namespace (URL scheme) with a HandlerFunc. Before registering, validateNamespace checks the name; any validation failure is wrapped as \"xlangx.RegisterHandler: %v\". This prevents namespaces that collide with the resolution syntax (e.g. containing ':') or reserved schemes.","triggerScenarios":"Calling xlangx.RegisterHandler with a namespace containing \":\" (the Separator) or equal to a restricted namespace such as \"localhost\" or \"http\".","commonSituations":"Dynamically constructing namespaces from user config that includes a scheme like \"http:\"; typos using a colon-separated \"namespace:urn\" form as the namespace; attempting to override built-in schemes.","solutions":["Remove ':' from the namespace string; register only the bare scheme/namespace.","Choose a non-reserved namespace distinct from \"localhost\", \"http\", etc.","Handle the returned error and surface a clear message to the configuring user.","Sanitize user-supplied namespace config before calling RegisterHandler."],"exampleFix":"// before\nerr := xlangx.RegisterHandler(\"my-ns:v1\", handler)\n// after\nerr := xlangx.RegisterHandler(\"my-ns-v1\", handler)","handlingStrategy":"validation","validationCode":"if strings.Contains(namespace, \":\") {\n    return fmt.Errorf(\"namespace %q must not contain ':'\", namespace)\n}","typeGuard":null,"tryCatchPattern":"if err := xlangx.RegisterHandler(ns, h); err != nil {\n    return fmt.Errorf(\"registering expansion handler for %q: %w\", ns, err)\n}","preventionTips":["Use bare identifiers without colons as namespaces","Avoid deriving namespaces from URLs or URNs","Sanitize user-supplied namespace config"],"tags":["go","validation","namespace","xlang"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}