{"record":{"id":"a30a1d25cdd4a395","repo":"ent/ent","slug":"enum-namedvalues-odd-argument-count","errorCode":null,"errorMessage":"Enum.NamedValues: odd argument count","messagePattern":"Enum\\.NamedValues: odd argument count","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/field/field.go","lineNumber":1060,"sourceCode":"\t}\n\treturn b\n}\n\n// NamedValues adds the given name, value pairs to the enum value.\n// The \"name\" defines the Go identifier of the enum, and the value\n// defines the actual value in the database.\n//\n// NamedValues returns an error if given an odd number of arguments.\n//\n//\tfield.Enum(\"priority\").\n//\t\tNamedValues(\n//\t\t\t\"Low\", \"LOW\",\n//\t\t\t\"Mid\", \"MID\",\n//\t\t\t\"High\", \"HIGH\",\n//\t\t)\nfunc (b *enumBuilder) NamedValues(namevalue ...string) *enumBuilder {\n\tif len(namevalue)%2 == 1 {\n\t\tb.desc.Err = fmt.Errorf(\"Enum.NamedValues: odd argument count\")\n\t\treturn b\n\t}\n\tfor i := 0; i < len(namevalue); i += 2 {\n\t\tb.desc.Enums = append(b.desc.Enums, struct{ N, V string }{N: namevalue[i], V: namevalue[i+1]})\n\t}\n\treturn b\n}\n\n// Default sets the default value of the field.\nfunc (b *enumBuilder) Default(value string) *enumBuilder {\n\tb.desc.Default = value\n\treturn b\n}\n\n// StorageKey sets the storage key of the field.\n// In SQL dialects is the column name and Gremlin is the property.\nfunc (b *enumBuilder) StorageKey(key string) *enumBuilder {\n\tb.desc.StorageKey = key","sourceCodeStart":1042,"sourceCodeEnd":1078,"githubUrl":"https://github.com/ent/ent/blob/69d5d4deb19599f129166634e09d33addcf3f2cc/schema/field/field.go#L1042-L1078","documentation":"Schema-definition error stored on the enum descriptor by enumBuilder.NamedValues: the variadic name/value list has an odd number of strings, so the trailing name has no paired value. The builder records the error on desc.Err (execution continues; the error surfaces at codegen), meaning the enum's NamedValues call is malformed — every Go identifier must be followed by its database value.","triggerScenarios":"Thrown at schema/field/field.go:1060 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure NamedValues receives an even number of arguments: \"Low\", \"LOW\", \"Mid\", \"MID\", ...","Count the pairs in the call site named by the codegen error and add the missing value string","Prefer a linter/editor check on the paired arguments when editing enum schemas"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"69d5d4deb19599f129166634e09d33addcf3f2cc","analyzedAt":"2026-09-03T16:51:39.799Z","contentChangedAt":"2026-09-03T16:51:39.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}