cilium/cilium · error
failed to serialize Paths: %w
Error message
failed to serialize Paths: %w
What it means
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.
Source
Thrown at pkg/bgp/api/conversions.go:209
path, err := ToAgentPath(m)
if err != nil {
errs = append(errs, err)
continue
}
ret = append(ret, path)
}
if len(errs) != 0 {
return nil, errors.Join(errs...)
}
return ret, nil
}
func ToAPIRoute(r *types.Route, routerASN int64, neighbor string) (*models.BgpRoute, error) {
paths, err := ToAPIPaths(r.Paths)
if err != nil {
return nil, fmt.Errorf("failed to serialize Paths: %w", err)
}
return &models.BgpRoute{
RouterAsn: routerASN,
Neighbor: neighbor,
Prefix: r.Prefix,
Paths: paths,
}, nil
}
func ToAgentRoute(m *models.BgpRoute) (*types.Route, error) {
paths, err := ToAgentPaths(m.Paths)
if err != nil {
return nil, fmt.Errorf("failed to deserialize Paths: %w", err)
}
return &types.Route{
Prefix: m.Prefix,
Paths: paths,
}, nilView on GitHub (pinned to ac7b90affa)
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)
Example fix
// before
paths, err := ToAPIPaths(r.Paths)
if err != nil { return nil, err } // one bad path kills the route
// after (caller-side isolation)
for _, p := range r.Paths {
ap, err := api.ToAPIPath(p)
if err != nil { log.Warnf("skipping path: %v", err); continue }
good = append(good, ap)
} Defensive patterns
Strategy: try-catch
Validate before calling
func routeConvertible(r *types.Route) error {
for _, p := range r.Paths {
if _, err := api.ToAPIPath(p); err != nil {
return fmt.Errorf("path %v: %w", p.NLRI, err)
}
}
return nil
} Try / catch
route, err := api.ToAPIRoute(r, asn, neighbor)
if err != nil {
log.Warnf("route %s skipped: %v", r.Prefix, err)
return nil // continue with remaining routes
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to serialize NLRI: %w
- failed to serialize Path Attribute: %w
- failed to deserialize Paths: %w
- Cannot marshal config: %w
- failed to fetch bgp state from %s: %w
AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31).
Data as JSON: /api/errors/993c3a9e644a1c79.
Report an issue: GitHub.