{"record":{"id":"993c3a9e644a1c79","repo":"cilium/cilium","slug":"failed-to-serialize-paths-w","errorCode":null,"errorMessage":"failed to serialize Paths: %w","messagePattern":"failed to serialize Paths: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bgp/api/conversions.go","lineNumber":209,"sourceCode":"\t\tpath, err := ToAgentPath(m)\n\t\tif err != nil {\n\t\t\terrs = append(errs, err)\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, path)\n\t}\n\n\tif len(errs) != 0 {\n\t\treturn nil, errors.Join(errs...)\n\t}\n\n\treturn ret, nil\n}\n\nfunc ToAPIRoute(r *types.Route, routerASN int64, neighbor string) (*models.BgpRoute, error) {\n\tpaths, err := ToAPIPaths(r.Paths)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to serialize Paths: %w\", err)\n\t}\n\treturn &models.BgpRoute{\n\t\tRouterAsn: routerASN,\n\t\tNeighbor:  neighbor,\n\t\tPrefix:    r.Prefix,\n\t\tPaths:     paths,\n\t}, nil\n}\n\nfunc ToAgentRoute(m *models.BgpRoute) (*types.Route, error) {\n\tpaths, err := ToAgentPaths(m.Paths)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to deserialize Paths: %w\", err)\n\t}\n\treturn &types.Route{\n\t\tPrefix: m.Prefix,\n\t\tPaths:  paths,\n\t}, nil","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/pkg/bgp/api/conversions.go#L191-L227","documentation":"ToAPIRoute converts an internal types.Route (a prefix plus its paths) into the API BgpRoute model. It delegates to ToAPIPaths, and this error propagates any NLRI or path-attribute serialization failure (errors 1750–1752) from any path in the route. The route prefix itself is fine; at least one of its paths could not be serialized.","triggerScenarios":"Calling ToAPIRoute (directly or via ToAPIRoutes / API route listing) when any path in r.Paths has a malformed NLRI, unsupported AFI/SAFI, or malformed path attribute — the whole route conversion aborts.","commonSituations":"Dumping the RIB over the gRPC/API when the table contains a path injected with invalid data; route refresh returning one bad path learned from a misbehaving peer, failing the entire routes listing.","solutions":["Look at the wrapped cause to identify which path and which component (NLRI/family/attribute) failed","Identify the offending path's source neighbor and withdraw it or fix the peer's configuration","Iterate paths individually with ToAPIPath to isolate the bad one and skip it if partial results are acceptable","Report/upgrade if the path came from standard gobgp operation (library bug)"],"exampleFix":"// before\npaths, err := ToAPIPaths(r.Paths)\nif err != nil { return nil, err } // one bad path kills the route\n// after (caller-side isolation)\nfor _, p := range r.Paths {\n    ap, err := api.ToAPIPath(p)\n    if err != nil { log.Warnf(\"skipping path: %v\", err); continue }\n    good = append(good, ap)\n}","handlingStrategy":"try-catch","validationCode":"func routeConvertible(r *types.Route) error {\n    for _, p := range r.Paths {\n        if _, err := api.ToAPIPath(p); err != nil {\n            return fmt.Errorf(\"path %v: %w\", p.NLRI, err)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"route, err := api.ToAPIRoute(r, asn, neighbor)\nif err != nil {\n    log.Warnf(\"route %s skipped: %v\", r.Prefix, err)\n    return nil // continue with remaining routes\n}","preventionTips":["Validate each path with ToAPIPath when importing externally sourced routes","Track which neighbor produced each path so bad ones can be traced","Keep per-path error isolation in bulk export code instead of failing whole tables"],"tags":["go","bgp","routing-table","serialization"],"backgroundTag":"bgp-nlri-serialization-failed","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}