{"record":{"id":"7a4c792cf65b595c","repo":"cilium/cilium","slug":"unable-to-understand-network-config-w","errorCode":null,"errorMessage":"unable to understand network config: %w","messagePattern":"unable to understand network config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/cilium-cni/chaining/generic-veth/generic-veth.go","lineNumber":35,"sourceCode":"\t\"github.com/cilium/cilium/api/v1/models\"\n\t\"github.com/cilium/cilium/pkg/client\"\n\t\"github.com/cilium/cilium/pkg/datapath/link\"\n\t\"github.com/cilium/cilium/pkg/datapath/linux/safenetlink\"\n\tendpointid \"github.com/cilium/cilium/pkg/endpoint/id\"\n\t\"github.com/cilium/cilium/pkg/logging/logfields\"\n\t\"github.com/cilium/cilium/pkg/mac\"\n\t\"github.com/cilium/cilium/pkg/netns\"\n\tchainingapi \"github.com/cilium/cilium/plugins/cilium-cni/chaining/api\"\n\t\"github.com/cilium/cilium/plugins/cilium-cni/lib\"\n\t\"github.com/cilium/cilium/plugins/cilium-cni/types\"\n)\n\ntype GenericVethChainer struct{}\n\nfunc (f *GenericVethChainer) Add(ctx context.Context, pluginCtx chainingapi.PluginContext, cli *client.Client) (res *cniTypesVer.Result, err error) {\n\terr = cniVersion.ParsePrevResult(&pluginCtx.NetConf.NetConf)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"unable to understand network config: %w\", err)\n\t\treturn\n\t}\n\n\tvar prevRes *cniTypesVer.Result\n\tprevRes, err = cniTypesVer.NewResultFromResult(pluginCtx.NetConf.PrevResult)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"unable to get previous network result: %w\", err)\n\t\treturn\n\t}\n\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tpluginCtx.Logger.Error(\n\t\t\t\t\"Unable to create endpoint\",\n\t\t\t\tlogfields.Error, err,\n\t\t\t\tlogfields.Previous, pluginCtx.NetConf.PrevResult,\n\t\t\t)\n\t\t}","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/plugins/cilium-cni/chaining/generic-veth/generic-veth.go#L17-L53","documentation":"The GenericVethChainer's Add step in the Cilium CNI chaining plugin first validates the previous plugin's result by calling cniVersion.ParsePrevResult on the chained NetConf. This error wraps the parse failure, meaning the CNI network configuration's prevResult field is missing or malformed for the plugin's CNI version.","triggerScenarios":"Invoking the generic-veth chaining plugin's Add when the input CNI config lacks a valid prevResult, has an unsupported/inconsistent cniVersion, or the prevResult does not match the declared version.","commonSituations":"Miswritten CNI conflist where the chaining plugin is ordered before a plugin that produces a result; hand-edited 10-cilium-cni.conf with missing prevResult; CNI spec version mismatches after upgrades.","solutions":["Fix the CNI chaining config so a prior plugin emits a result before generic-veth runs (correct plugin ordering in the list)","Validate the conflist JSON (e.g. with cnitool or a JSON schema check) for a well-formed prevResult","Ensure the cniVersion fields are consistent (0.3.1/0.4.0+) across chained plugins","Inspect the wrapped error to pinpoint whether prevResult is absent or unparseable"],"exampleFix":"// before\n{\"cniVersion\":\"0.3.1\",\"name\":\"veth\",\"plugins\":[{\"type\":\"cilium-cni\"},{\"type\":\"generic-veth\"}]}\n// after\n{\"cniVersion\":\"0.3.1\",\"name\":\"veth\",\"plugins\":[{\"type\":\"portmap\",...},{\"type\":\"cilium-cni\"},{\"type\":\"generic-veth\"}]} // a producing plugin precedes generic-veth, so prevResult is populated","handlingStrategy":"validation","validationCode":"// validate the CNI config before invoking the plugin\nvar netConf struct {\n    cniTypes.NetConf\n}\nif err := json.Unmarshal(configBytes, &netConf); err != nil {\n    return fmt.Errorf(\"invalid CNI config: %w\", err)\n}\nif netConf.PrevResult == nil && netConf.RawPrevResult == nil {\n    return fmt.Errorf(\"prevResult missing: a prior plugin must run before generic-veth\")\n}","typeGuard":"func hasValidPrevResult(netConf *chainingapi.PluginContext) bool {\n    if netConf == nil || netConf.NetConf.PrevResult == nil {\n        return false\n    }\n    return cniVersion.GreaterThanOrEqualTo(netConf.NetConf.CNIVersion, \"0.3.0\")\n}","tryCatchPattern":"res, err := chainer.Add(ctx, pluginCtx, cli)\nif err != nil && strings.Contains(err.Error(), \"unable to understand network config\") {\n    // fail the CNI ADD clearly so kubelet surfaces the malformed config\n    return nil, fmt.Errorf(\"chaining config invalid, check plugin ordering/prevResult: %w\", err)\n}","preventionTips":["Keep the chaining conflist ordered so plugins that produce results precede generic-veth","Validate CNI conflist JSON with the CNI spec schema after every manual edit","Keep cniVersion consistent (>= 0.3.1) across all chained plugins","Test CNI chains with cnitool in CI before rolling out node upgrades"],"tags":["cni","cilium","config-validation"],"backgroundTag":"cni-prevresult-invalid","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}