{"record":{"id":"2e86c863611949f8","repo":"cilium/cilium","slug":"out-cannot-be-empty","errorCode":null,"errorMessage":"out cannot be empty","messagePattern":"out cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/dpgen/main.go","lineNumber":51,"sourceCode":"\t\tLong: `Generates a configuration struct from a single datapath object.\n\nThe struct is generated based on global variables in the object file with a\ndecl tag matching the provided kind (e.g. \"kind:object\"). Optionally, additional\nstructs can be embedded in the generated struct with the --embed flag.\n\nUse with go:generate in a Go source file (e.g. gen.go) to automatically detect\nthe current package name:\n\n    //go:generate go tool dpgen config --embed Node --kind object --name BPFLXC --out lxc_config.go ../../../bpf/bpf_lxc.o`,\n\t\tPreRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif configOpts.embed != \"\" {\n\t\t\t\tconfigOpts.embeds = strings.Split(configOpts.embed, \",\")\n\t\t\t}\n\t\t\tif configOpts.outName == \"\" {\n\t\t\t\treturn fmt.Errorf(\"name cannot be empty\")\n\t\t\t}\n\t\t\tif configOpts.outFile == \"\" {\n\t\t\t\treturn fmt.Errorf(\"out cannot be empty\")\n\t\t\t}\n\t\t\tif configOpts.kind == \"\" {\n\t\t\t\treturn fmt.Errorf(\"kind cannot be empty\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tRunE: runConfig,\n\t\tArgs: cobra.ExactArgs(1),\n\t}\n\n\tflags := c.Flags()\n\tflags.StringVar(&configOpts.outFile, \"out\", \"\", \"output Go source file for the generated config struct\")\n\tflags.StringVar(&configOpts.outName, \"name\", \"\", \"name of the generated Go struct in the output file\")\n\tflags.StringVar(&configOpts.kind, \"kind\", \"object\", \"variables to include based on their decl tags (kind:object, kind:node, ...)\")\n\tflags.StringVar(&configOpts.embed, \"embed\", \"\", \"comma-separated list of Go structs to embed in the generated struct\")\n\tflags.StringVar(&configOpts.typesPkg, \"types\", \"github.com/cilium/cilium/pkg/datapath/types\", \"package containing external types managed by 'dpgen type'\")\n\n\tflags.StringVarP(&configOpts.goPkg, \"package\", \"p\", os.Getenv(\"GOPACKAGE\"), \"name of the Go package dpgen was invoked for/from (default $GOPACKAGE)\")","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/cilium/cilium/blob/ac7b90affa4baf0642e6685319d56907b3a73a6d/tools/dpgen/main.go#L33-L69","documentation":"The dpgen 'config' subcommand requires --out, the path of the Go file to write the generated code into. This PreRunE validation fires when --out is missing or empty, aborting before generation. It guarantees the tool never writes to an unspecified destination.","triggerScenarios":"Invoking 'dpgen config --embed X --kind object --name Y <obj.o>' without --out, so configOpts.outFile is empty.","commonSituations":"Omitting --out when scripting codegen; a typo like -output instead of --out; deleting the --out portion of a copied go:generate line.","solutions":["Add --out <file>.go to the command line (e.g. --out lxc_config.go).","Check the //go:generate directive for the --out flag and a valid filename.","Run 'dpgen config --help' to confirm flag names."],"exampleFix":"// before\n//go:generate go tool dpgen config --embed Node --kind object --name BPFLXC ../../../bpf/bpf_lxc.o\n// after\n//go:generate go tool dpgen config --embed Node --kind object --name BPFLXC --out lxc_config.go ../../../bpf/bpf_lxc.o","handlingStrategy":"validation","validationCode":"if outFile == \"\" { return fmt.Errorf(\"--out is required for dpgen config\") }; if !strings.HasSuffix(outFile, \".go\") { return fmt.Errorf(\"--out %q should be a .go file\", outFile) }","typeGuard":"func hasOut(args []string) bool { for i, a := range args { if a == \"--out\" && i+1 < len(args) && args[i+1] != \"\" { return true } } return false }","tryCatchPattern":null,"preventionTips":["Include --out with a concrete filename in every config directive.","Verify generated-file paths are gitignore'd or committed per team convention.","Add a CI step running go generate and committing diffs to catch missing flags.","Lint //go:generate lines for the required flags."],"tags":["cli","validation","go","codegen"],"backgroundTag":"missing-required-flag","analyzedSha":"ac7b90affa4baf0642e6685319d56907b3a73a6d","analyzedAt":"2026-08-31T18:27:15.868Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}