dagger/dagger · error

invalid enum name null

Error message

invalid enum name null

What it means

Same EnumValueName construction path as the bool case: when the decoded payload is JSON null (Go nil interface), the constructor rejects it with the fixed message "invalid enum name null". dagql enums require an explicit registered member name; null is not a member, so nulls reaching an enum input surface as this error.

Source

Thrown at dagql/types.go:1794

func (e *EnumValueName) ToLiteral() call.Literal {
	return call.NewLiteralEnum(e.Name)
}

func (e *EnumValueName) Decoder() InputDecoder {
	return e
}

func (e *EnumValueName) DecodeInput(val any) (Input, error) {
	switch x := val.(type) {
	case *EnumValueName:
		return &EnumValueName{Enum: e.Enum, Name: x.Name}, nil
	case string:
		return &EnumValueName{Enum: e.Enum, Name: x}, nil
	case bool:
		return nil, fmt.Errorf("invalid enum name %t", x)
	case nil:
		return nil, fmt.Errorf("invalid enum name null")
	default:
		return nil, fmt.Errorf("cannot create enum name from %T", x)
	}
}

func (e *EnumValueName) MarshalJSON() ([]byte, error) {
	return json.Marshal(e.Name)
}

func MustInputSpec(val Type) InputObjectSpec {
	spec := InputObjectSpec{
		Name: val.TypeName(),
	}
	if desc, ok := val.(Descriptive); ok {
		spec.Description = desc.TypeDescription()
	}
	inputs, err := InputSpecsForType(val, true)
	if err != nil {

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Omit the variable from the request entirely rather than sending null, or send a valid registered member name.
  2. Use omit-on-empty serialization in client code so unset enums are never emitted as null.
  3. If absence should be allowed, mark the argument optional in the schema and ensure the SDK skips nil values; otherwise update callers to pass a concrete member.

Example fix

// before
vars := map[string]any{"platform": nil}
// after
delete(vars, "platform") // omit instead of sending null
Defensive patterns

Strategy: validation

Validate before calling

func isNullPayload(raw []byte) bool {
    var v any
    if err := json.Unmarshal(raw, &v); err != nil {
        return false
    }
    return v == nil
}

Try / catch

if err := dagql.DecodeInput(&target, input); err != nil {
    if strings.Contains(err.Error(), "invalid enum name null") {
        return handleMissingEnum() // treat as unset, not a hard failure
    }
    return err
}

Prevention

When it happens

Trigger: Decoding an enum-typed input whose JSON value is null (e.g. {"enumArg": null}), or passing an untyped nil to the enum-name constructor — typically an unset GraphQL variable typed as an enum.

Common situations: GraphQL variables where an optional enum argument is explicitly set to null instead of omitted; SDKs serializing unset fields as null; clients built against schemas where the argument recently became non-nullable.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/3d350029d3e903da. Report an issue: GitHub.