{"record":{"id":"2e825a631af3548c","repo":"dagger/dagger","slug":"t-getdecoder-incorrect-type-t-for-scalar","errorCode":null,"errorMessage":"%T.getDecoder: incorrect type %T for scalar","messagePattern":"%T\\.getDecoder: incorrect type %T for scalar","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/enum.go","lineNumber":115,"sourceCode":"func (m *ModuleEnumType) CollectContent(ctx context.Context, value dagql.AnyResult, content *CollectedContent) error {\n\tif value == nil {\n\t\treturn content.CollectJSONable(nil)\n\t}\n\treturn content.CollectJSONable(value.Unwrap())\n}\n\nfunc (m *ModuleEnumType) getEnum(ctx context.Context) (*ModuleEnum, error) {\n\t// Check the dependencies\n\tsrv, err := m.mod.Self().Deps.Schema(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%T.getDecoder: failed to get schema: %w\", m, err)\n\t}\n\n\tscalar, ok := srv.ScalarType(m.typeDef.Name)\n\tif ok {\n\t\tenum, ok := scalar.(*ModuleEnum)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"%T.getDecoder: incorrect type %T for scalar\", m, scalar)\n\t\t}\n\t\treturn enum, nil\n\t}\n\n\t// If not check if the enum is part of its own module\n\tfor _, enumTypeDef := range m.mod.Self().EnumDefs {\n\t\tif enumTypeDef.Self().AsEnum.Value.Self().Name == m.typeDef.Name {\n\t\t\treturn &ModuleEnum{TypeDef: enumTypeDef.Self().AsEnum.Value.Self(), Local: true}, nil\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"%T.getDecoder: failed to get enum type %q\", m, m.typeDef.Name)\n}\n\ntype ModuleEnum struct {\n\tTypeDef *EnumTypeDef\n\tName    string\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/enum.go#L97-L133","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (dep): type Status scalar { ... }  // was enum\n// after (dep): enum Status { UNKNOWN ACTIVE }","handlingStrategy":"type-guard","validationCode":"sc, ok := srv.ScalarType(enumName)\nif ok {\n    if _, isEnum := sc.(*ModuleEnum); !isEnum {\n        return fmt.Errorf(\"%s is registered as %T, not an enum\", enumName, sc)\n    }\n}","typeGuard":"func isModuleEnum(sc dagql.ScalarType) (*ModuleEnum, bool) {\n    e, ok := sc.(*ModuleEnum)\n    return e, ok\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"incorrect type\") {\n    return fmt.Errorf(\"type name collision on %s: rename one of the definitions\", enumName)\n}","preventionTips":["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"],"tags":["enum","name-collision","schema","dagger"],"backgroundTag":"type-name-collision","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"}