dagger/dagger · error
%T.getDecoder: incorrect type %T for scalar
Error message
%T.getDecoder: incorrect type %T for scalar
What it means
getEnum found a scalar registered under the enum's name in the dependency schema, but type-asserting it to *ModuleEnum failed — the name is taken by a different scalar kind. This is a name-collision / definition-mismatch error between what the module expects and what the dependency schema actually provides.
Source
Thrown at core/enum.go:115
func (m *ModuleEnumType) CollectContent(ctx context.Context, value dagql.AnyResult, content *CollectedContent) error {
if value == nil {
return content.CollectJSONable(nil)
}
return content.CollectJSONable(value.Unwrap())
}
func (m *ModuleEnumType) getEnum(ctx context.Context) (*ModuleEnum, error) {
// Check the dependencies
srv, err := m.mod.Self().Deps.Schema(ctx)
if err != nil {
return nil, fmt.Errorf("%T.getDecoder: failed to get schema: %w", m, err)
}
scalar, ok := srv.ScalarType(m.typeDef.Name)
if ok {
enum, ok := scalar.(*ModuleEnum)
if !ok {
return nil, fmt.Errorf("%T.getDecoder: incorrect type %T for scalar", m, scalar)
}
return enum, nil
}
// If not check if the enum is part of its own module
for _, enumTypeDef := range m.mod.Self().EnumDefs {
if enumTypeDef.Self().AsEnum.Value.Self().Name == m.typeDef.Name {
return &ModuleEnum{TypeDef: enumTypeDef.Self().AsEnum.Value.Self(), Local: true}, nil
}
}
return nil, fmt.Errorf("%T.getDecoder: failed to get enum type %q", m, m.typeDef.Name)
}
type ModuleEnum struct {
TypeDef *EnumTypeDef
Name string
View on GitHub (pinned to 82ba2681db)
Solutions
- Rename the enum or the colliding scalar so names are unique across modules
- Pin/update the dependency to a version where the type is still an enum
- Clear the module cache and rebuild so the schema reflects current dependency code
- Coordinate with the dependency maintainer if the upstream type kind changed
Example fix
// before (dep): type Status scalar { ... } // was enum
// after (dep): enum Status { UNKNOWN ACTIVE } Defensive patterns
Strategy: type-guard
Validate before calling
sc, ok := srv.ScalarType(enumName)
if ok {
if _, isEnum := sc.(*ModuleEnum); !isEnum {
return fmt.Errorf("%s is registered as %T, not an enum", enumName, sc)
}
} Type guard
func isModuleEnum(sc dagql.ScalarType) (*ModuleEnum, bool) {
e, ok := sc.(*ModuleEnum)
return e, ok
} Try / catch
if err != nil && strings.Contains(err.Error(), "incorrect type") {
return fmt.Errorf("type name collision on %s: rename one of the definitions", enumName)
} Prevention
- Keep type names unique across your module and its dependencies
- Avoid changing a type's kind (scalar <-> enum) in published versions
- Clean the module cache when switching dependency versions
When it happens
Trigger: A dependency module registers a plain custom scalar (or other scalar type) with the same name as the enum this module references, then getEnum's `scalar.(*ModuleEnum)` assertion fails.
Common situations: A dependency changed an enum into a custom scalar (or vice versa) in a newer version; two modules defining different kinds under the same type name; stale local cache mixing old and new schema.
Related errors
- %T.getDecoder: failed to get schema: %w
- unknown type %q
- enum types must be named
- failed to find decl for object %s: %w
- failed to find decl for named type %s: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/2e825a631af3548c.
Report an issue: GitHub.