{"record":{"id":"5e4615c2960430f5","repo":"cloudflare/cloudflared","slug":"error-parsing-cidr-string","errorCode":null,"errorMessage":"error parsing cidr string","messagePattern":"error parsing cidr string","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cfapi/ip_route.go","lineNumber":53,"sourceCode":"func (c CIDR) String() string {\n\tn := net.IPNet(c)\n\treturn n.String()\n}\n\nfunc (c CIDR) MarshalJSON() ([]byte, error) {\n\tstr := c.String()\n\tjson, err := json.Marshal(str)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error serializing CIDR into JSON\")\n\t}\n\treturn json, nil\n}\n\n// UnmarshalJSON parses a JSON string into net.IPNet\nfunc (c *CIDR) UnmarshalJSON(data []byte) error {\n\tvar s string\n\tif err := json.Unmarshal(data, &s); err != nil {\n\t\treturn errors.Wrap(err, \"error parsing cidr string\")\n\t}\n\t_, network, err := net.ParseCIDR(s)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"error parsing invalid network from backend\")\n\t}\n\tif network == nil {\n\t\treturn fmt.Errorf(\"backend returned invalid network %s\", s)\n\t}\n\t*c = CIDR(*network)\n\treturn nil\n}\n\n// NewRoute has all the parameters necessary to add a new route to the table.\ntype NewRoute struct {\n\tNetwork  net.IPNet\n\tTunnelID uuid.UUID\n\tComment  string\n\t// Optional field. If unset, backend will assume the default vnet for the account.","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cfapi/ip_route.go#L35-L71","documentation":"Deserialization guard in cfapi CIDR.UnmarshalJSON: the JSON value for a CIDR field is not a JSON string, so unmarshalling into a string fails before net.ParseCIDR is attempted. Indicates a malformed route payload from the Tunnelstore backend.","triggerScenarios":"Thrown at cfapi/ip_route.go:53 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the raw JSON response — the CIDR field must be a string like '10.0.0.0/8'.","Check for API version drift or a proxy rewriting the response body.","Retry the request; persistent malformation should be reported."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}