{"record":{"id":"d6e5df034ecd99f0","repo":"dagger/dagger","slug":"unknown-enum-value-v","errorCode":null,"errorMessage":"unknown enum value %v","messagePattern":"unknown enum value (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generator/go/templates/module_funcs.go","lineNumber":265,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"failed to generate arg type code: %w\", err)\n\t\t}\n\t\tif argSpec.optional {\n\t\t\targTypeDefCode = argTypeDefCode.Dot(\"WithOptional\").Call(Lit(true))\n\t\t}\n\n\t\targOptsCode := []Code{}\n\t\tif argSpec.description != \"\" {\n\t\t\targOptsCode = append(argOptsCode, Id(\"Description\").Op(\":\").Lit(strings.TrimSpace(argSpec.description)))\n\t\t}\n\t\tif argSpec.sourceMap != nil {\n\t\t\targOptsCode = append(argOptsCode, Id(\"SourceMap\").Op(\":\").Add(argSpec.sourceMap.TypeDefCode()))\n\t\t}\n\t\tif argSpec.hasDefaultValue {\n\t\t\tvar defaultValue string\n\t\t\tif enumType, ok := argSpec.typeSpec.(*parsedEnumTypeReference); ok {\n\t\t\t\tv, ok := argSpec.defaultValue.(string)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unknown enum value %v\", argSpec.defaultValue)\n\t\t\t\t}\n\t\t\t\tres := enumType.lookup(v)\n\t\t\t\tif res == nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"unknown enum value %q\", v)\n\t\t\t\t}\n\t\t\t\tdefaultValue = strconv.Quote(res.name)\n\t\t\t} else {\n\t\t\t\tv, err := json.Marshal(argSpec.defaultValue)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"could not encode default value %q: %w\", argSpec.defaultValue, err)\n\t\t\t\t}\n\t\t\t\tdefaultValue = string(v)\n\t\t\t}\n\t\t\targOptsCode = append(argOptsCode, Id(\"DefaultValue\").Op(\":\").Id(\"dagger\").Dot(\"JSON\").Call(Lit(defaultValue)))\n\t\t}\n\n\t\tif argSpec.defaultPath != \"\" {\n\t\t\targOptsCode = append(argOptsCode, Id(\"DefaultPath\").Op(\":\").Lit(argSpec.defaultPath))","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generator/go/templates/module_funcs.go#L247-L283","documentation":"For an argument whose type is an enum and which has a default value, the default must be a string naming an enum member. If argSpec.defaultValue is not a string (e.g. a number or bool), codegen cannot even look it up and fails with \"unknown enum value %v\".","triggerScenarios":"Annotating an enum-typed argument with a default value that isn't a string — for example a numeric or boolean default in the pragma/annotation, or a corrupted parse that stored a non-string default.","commonSituations":"Copy-pasting default-value annotations from an int-typed argument to an enum-typed one; hand-writing default pragmas with wrong literal types.","solutions":["Change the default value to a string matching one of the enum's member names","Verify the argument's type is actually the enum you intend; fix the type if it should be an int/bool","Remove the default value if none is appropriate","Regenerate the module"],"exampleFix":"// before\n// +default=42\n\tlevel MyEnum,\n\n// after\n// +default=\"high\"\n\tlevel MyEnum,","handlingStrategy":"validation","validationCode":"// ensure enum argument defaults are strings matching member names\n// wrong: +default=3 on an enum arg; right: +default=\"memberName\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote string defaults for enum-typed arguments","Confirm the argument's declared type before attaching a default","Review pragma annotations when changing an argument's type"],"tags":["dagger","codegen","enum","default-value"],"backgroundTag":"invalid-enum-default-value","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}