{"record":{"id":"d05ea6ab7b9cd809","repo":"dagger/dagger","slug":"mark-local-s-type-w-d05ea6","errorCode":null,"errorMessage":"mark local %s type: %w","messagePattern":"mark local (.+?) type: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/sdk/dang/v2/helpers.go","lineNumber":476,"sourceCode":"\treturn \"DangSDKLocalType\" + name\n}\n\nfunc withDangLocalName[T dagql.Typed](\n\tctx context.Context,\n\tsrv *dagql.Server,\n\ttypeDef dagql.ObjectResult[*core.TypeDef],\n\tres dagql.ObjectResult[T],\n\ttemporaryName string,\n\tkind string,\n\twithField string,\n\targName string,\n) (dagql.ObjectResult[*core.TypeDef], error) {\n\tvar renamed dagql.ObjectResult[T]\n\tif err := srv.Select(ctx, res, &renamed, dagql.Selector{\n\t\tField: \"__withName\",\n\t\tArgs:  []dagql.NamedInput{{Name: \"name\", Value: dagql.String(temporaryName)}},\n\t}); err != nil {\n\t\treturn typeDef, fmt.Errorf(\"mark local %s type: %w\", kind, err)\n\t}\n\trenamedID, err := core.ResultIDInput(renamed)\n\tif err != nil {\n\t\treturn typeDef, fmt.Errorf(\"local %s type ID: %w\", kind, err)\n\t}\n\tvar updated dagql.ObjectResult[*core.TypeDef]\n\tif err := srv.Select(ctx, typeDef, &updated, dagql.Selector{\n\t\tField: withField,\n\t\tArgs:  []dagql.NamedInput{{Name: argName, Value: renamedID}},\n\t}); err != nil {\n\t\treturn typeDef, fmt.Errorf(\"mark local %s typedef: %w\", kind, err)\n\t}\n\treturn updated, nil\n}\n\n// markDangLocalType gives a local Dang type a temporary, non-core schema name\n// while preserving its OriginalName. Core's Module.WithObject namespacing later\n// uses OriginalName to produce the final module-prefixed name; the temporary","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/sdk/dang/v2/helpers.go#L458-L494","documentation":"This error wraps a failure from the internal dagql `__withName` selection performed while giving a local Dang type a temporary non-core schema name (e.g. `DangSDKLocalType<Name>`) via `withDangLocalName`, invoked by `markDangLocalType`. The temporary rename prevents local type names like `Container` from colliding with core schema types before module namespacing runs. When the GraphQL-style selection that renames the type fails, the error is wrapped with the type `kind` (object, interface, or enum) and propagated, aborting module initialization.","triggerScenarios":"Calling `markDangLocalType` on a TypeDef whose underlying Object/Interface/Enum value fails the `srv.Select(ctx, res, &renamed, {Field: \"__withName\", ...})` call — e.g. the dagql server rejects the `__withName` selector for that type, the context is cancelled, or the underlying object result is invalid.","commonSituations":"A user module defines a local type whose name shadows a core type (like `Container`); during SDK module init the temporary rename step fails because the dagql server cannot serve `__withName` for that kind, or the engine call fails mid-initialization.","solutions":["Inspect the wrapped inner error (`%w` chain) to find the actual dagql failure for the `__withName` selector.","Check that the TypeDef's AsObject/AsInterface/AsEnum value is non-nil and valid before marking.","Verify the dagger engine/dagql server version supports the internal `__withName` field.","Retry module initialization if the failure was due to a transient context cancellation or engine error."],"exampleFix":"// before: opaque failure deep in init\nmod, err := sdk.InitDangModule(ctx, srv, env)\n// after: surface the wrapped cause\nif err != nil {\n    log.Fatalf(\"init module: %v (see unwrapped: %+v)\", err, errors.Unwrap(err))\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"mod, err := initDangModule(ctx, srv, env)\nif err != nil {\n    if strings.Contains(err.Error(), \"mark local\") {\n        var dagqlErr error\n        if errors.As(err, &dagqlErr) { /* inspect inner dagql failure */ }\n        return fmt.Errorf(\"local type rename failed during module init: %w\", err)\n    }\n    return err\n}","preventionTips":["Avoid naming local types exactly after core types unless shadowing is intended and supported.","Keep the dagger engine and Dang SDK versions aligned.","Log the fully unwrapped error chain during module development.","Validate TypeDef kind and value are populated before module init."],"tags":["dagql","dang-sdk","module-initialization","type-naming"],"backgroundTag":"dagql-select-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}