{"record":{"id":"f6c601e6394d1779","repo":"cilium/cilium","slug":"building-btf-spec-w","errorCode":null,"errorMessage":"building BTF spec: %w","messagePattern":"building BTF spec: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/dpgen/types.go","lineNumber":74,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\tfor _, v := range sorted(cs.Variables) {\n\t\t\t// We can skip aux variables as they are only used from the BPF side.\n\t\t\tif v.SectionName == auxSection {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err := addVariableType(bb, added, v); err != nil {\n\t\t\t\treturn fmt.Errorf(\"adding type for variable %s: %w\", v.Name, err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Pull a BTF spec out of the builder, allowing us to query the merged type\n\t// collection.\n\tspec, err := bb.Spec()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"building BTF spec: %w\", err)\n\t}\n\n\tb := bytes.Buffer{}\n\tif err := writeHeader(&b, typesOpts.goPkg, []string{\"structs\"}); err != nil {\n\t\treturn fmt.Errorf(\"writing header: %w\", err)\n\t}\n\n\tgf := btf.GoFormatter{Identifier: camelCase}\n\tfor t := range sortedSeq(added.Members()) {\n\t\t// Look up all added root types by name to: 1. avoid emitting type decls for\n\t\t// embedded types, and 2. ensure all types with the same name deduplicated\n\t\t// into one concrete type. This lookup will fail if there are multiple\n\t\t// incompatible candidate types with the same name across objects.\n\t\ttyp, err := spec.AnyTypeByName(t)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"getting BTF type %v: %w\", t, err)\n\t\t}\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/tools/dpgen/types.go#L56-L92","documentation":"After all maps and variables have been added, runTypes calls bb.Spec() to materialize the merged, deduplicated BTF spec used for type queries. This error wraps a failure producing that spec. Since inputs were already accepted individually, failure here indicates the accumulated type collection is internally inconsistent (e.g. irreconcilable duplicates) or the builder rejected the merge.","triggerScenarios":"dpgen -types with a set of ELF objects whose combined added types cannot be turned into a single btf.Spec by btf.Builder.Spec().","commonSituations":"Two globbed objects contribute same-name but structurally different types that deduplication could not collapse; a very large or malformed set of types triggering a builder limitation; version mismatch between the objects' BTF and the cilium/ebpf builder expectations.","solutions":["Rebuild all globbed BPF objects from one consistent set of headers so same-name types are identical.","Narrow the glob to the objects actually needed, removing the one introducing conflicting types.","Upgrade cilium/ebpf; builder/dedup bugs are fixed over time.","Bisect the object set: run dpgen -types on halves of the glob to isolate the conflicting object.","Inspect `bpftool btf dump file <o>` output of each object for duplicate type names with differing definitions."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := runTypes(...); err != nil {\n    if strings.Contains(err.Error(), \"building BTF spec\") {\n        return fmt.Errorf(\"merged BTF inconsistent; rebuild all objects from one header set or narrow the glob: %w\", err)\n    }\n    return err\n}","preventionTips":["Rebuild all globbed BPF objects together from the same headers before generating.","Bisect the object glob when this error appears to isolate conflicting objects.","Keep cilium/ebpf current; builder/dedup bugs get fixed upstream.","Diff same-name types across objects with bpftool btf dump to prevent merge conflicts."],"tags":["go","ebpf","btf"],"backgroundTag":"btf-type-resolution-failed","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}