{"record":{"id":"5a7e90d4ff7cb81a","repo":"cilium/cilium","slug":"unsupported-ip-address-format","errorCode":null,"errorMessage":"unsupported IP address format","messagePattern":"unsupported IP address format","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/endpointmanager/errors.go","lineNumber":12,"sourceCode":"// SPDX-License-Identifier: Apache-2.0\n// Copyright Authors of Cilium\n\npackage endpointmanager\n\nimport (\n\t\"errors\"\n)\n\nvar (\n\t// ErrUnsupportedID represents an error of unsupported IP address format.\n\tErrUnsupportedID = errors.New(\"unsupported IP address format\")\n)\n\n// ErrInvalidPrefix represents the error of an invalid prefix.\ntype ErrInvalidPrefix struct {\n\t// InvalidPrefix contains the invalid prefix.\n\tInvalidPrefix string\n}\n\n// Error returns the string representation of the ErrInvalidPrefix.\nfunc (e ErrInvalidPrefix) Error() string {\n\treturn \"unknown endpoint prefix '\" + e.InvalidPrefix + \"'\"\n}\n\n// IsErrUnsupportedID returns true if the given error is the type of\n// ErrUnsupportedID.\nfunc IsErrUnsupportedID(err error) bool {\n\treturn errors.Is(err, ErrUnsupportedID)\n}","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/endpointmanager/errors.go#L1-L30","documentation":"ErrUnsupportedID indicates that an IP address string supplied to the endpoint manager could not be parsed or is in an unsupported format, so no endpoint ID can be derived from it. Lookup returns it when the given identifier is not a recognized IP/prefix form.","triggerScenarios":"Calling endpointmanager Lookup (or helpers checked via IsErrUnsupportedID) with a malformed IP string, an IPv6 form where only IPv4 is supported, or an address family/format outside the supported set.","commonSituations":"Passing hostnames instead of IPs; passing CIDR strings where bare IPs are expected; typo'd or empty IP values from external integrations.","solutions":["Validate the IP with net.ParseIP (or netip.ParseAddr) before calling Lookup.","Normalize the input (strip whitespace, handle CIDR via netip.ParsePrefix if prefixes are acceptable).","Use errors.Is(err, manager.ErrUnsupportedID) to distinguish format problems from 'endpoint not found' and surface a client-side validation message.","Ensure the correct address family is enabled in the Cilium configuration (IPv4/IPv6)."],"exampleFix":"// before\nep, err := mgr.Lookup(userInput)\nif err != nil {\n    return err\n}\n// after\nif net.ParseIP(strings.TrimSpace(userInput)) == nil {\n    return fmt.Errorf(\"%q is not a valid IP address\", userInput)\n}\nep, err := mgr.Lookup(userInput)\nif errors.Is(err, manager.ErrUnsupportedID) {\n    return fmt.Errorf(\"unsupported IP format %q\", userInput)\n}","handlingStrategy":"validation","validationCode":"func validIP(s string) bool {\n    return net.ParseIP(strings.TrimSpace(s)) != nil\n}","typeGuard":"func isErrUnsupportedID(err error) bool {\n    return errors.Is(err, manager.ErrUnsupportedID)\n}","tryCatchPattern":"ep, err := mgr.Lookup(id)\nif errors.Is(err, manager.ErrUnsupportedID) {\n    return fmt.Errorf(\"invalid identifier %q: must be a supported IP\", id)\n}","preventionTips":["Parse and validate IPs with net.ParseIP/netip.ParseAddr before lookups","Strip whitespace and reject empty input early","Distinguish format errors (ErrUnsupportedID) from not-found errors in error handling"],"tags":["cilium","ip-validation","input-validation"],"backgroundTag":"unsupported-ip-format","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}