ent/ent · error
Enum.NamedValues: odd argument count
Error message
Enum.NamedValues: odd argument count
What it means
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.
Source
Thrown at schema/field/field.go:1060
}
return b
}
// NamedValues adds the given name, value pairs to the enum value.
// The "name" defines the Go identifier of the enum, and the value
// defines the actual value in the database.
//
// NamedValues returns an error if given an odd number of arguments.
//
// field.Enum("priority").
// NamedValues(
// "Low", "LOW",
// "Mid", "MID",
// "High", "HIGH",
// )
func (b *enumBuilder) NamedValues(namevalue ...string) *enumBuilder {
if len(namevalue)%2 == 1 {
b.desc.Err = fmt.Errorf("Enum.NamedValues: odd argument count")
return b
}
for i := 0; i < len(namevalue); i += 2 {
b.desc.Enums = append(b.desc.Enums, struct{ N, V string }{N: namevalue[i], V: namevalue[i+1]})
}
return b
}
// Default sets the default value of the field.
func (b *enumBuilder) Default(value string) *enumBuilder {
b.desc.Default = value
return b
}
// StorageKey sets the storage key of the field.
// In SQL dialects is the column name and Gremlin is the property.
func (b *enumBuilder) StorageKey(key string) *enumBuilder {
b.desc.StorageKey = keyView on GitHub (pinned to 69d5d4deb1)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at schema/field/field.go:1060 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ent/ent@69d5d4deb1 (2026-09-03).
Data as JSON: /api/errors/a30a1d25cdd4a395.
Report an issue: GitHub.