{"record":{"id":"875d6c5d32cd79c1","repo":"dagger/dagger","slug":"failed-to-apply-generated-code-w","errorCode":null,"errorMessage":"failed to apply generated code: %w","messagePattern":"failed to apply generated code: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/codegen.go","lineNumber":68,"sourceCode":"\t\tintrospectionSchemaVersion = resp.SchemaVersion\n\t} else {\n\t\tintrospectionSchema, introspectionSchemaVersion, err = introspection.Introspect(ctx, cfg.Dag)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Set the parent schema\n\tgenerator.SetSchemaParents(introspectionSchema)\n\n\tfor ctx.Err() == nil {\n\t\tgenerated, err := genFunc(ctx, introspectionSchema, introspectionSchemaVersion)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := generator.Apply(ctx, generated, cfg.OutputDir); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to apply generated code: %w\", err)\n\t\t}\n\n\t\tfor _, cmd := range generated.PostCommands {\n\t\t\t// Only set cmd.Dir if the command hasn't already specified one.\n\t\t\t// This allows generators to target a specific sub-directory (e.g.\n\t\t\t// the client module directory) without being overridden here.\n\t\t\tif cmd.Dir == \"\" {\n\t\t\t\tcmd.Dir = cfg.OutputDir\n\t\t\t\tif cfg.ModuleConfig != nil && cfg.ModuleConfig.ModuleName != \"\" {\n\t\t\t\t\tcmd.Dir = filepath.Join(cfg.OutputDir, cfg.ModuleConfig.ModuleSourcePath)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcmd.Stdout = os.Stdout\n\t\t\tcmd.Stderr = os.Stderr\n\t\t\tslog.Info(\"running post-command:\", \"args\", strings.Join(cmd.Args, \" \"))\n\t\t\terr := cmd.Run()\n\t\t\tif err != nil {\n\t\t\t\tslog.Error(\"post-command failed\", \"error\", err)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/codegen.go#L50-L86","documentation":"After building the decode resolver, dagql extracts the underlying *Server (dagql server) from it via resolverServer to decode the result. If the resolver implementation does not expose a dagql server, decoding cannot proceed and this error names the concrete resolver Go type.","triggerScenarios":"resolverServer(decodeResolver) returns nil in ensurePersistedHitValueLoaded — the TypeResolver handed in (from e.g. loadResultByResultID's dag *Server or a wrapping resolver) does not implement the server-providing interface.","commonSituations":"Embedding dagql in a custom host with a minimal TypeResolver implementation; calling LoadResultByResultID with a resolver that is not backed by a *Server; test doubles used in production import paths.","solutions":["Pass the actual dagql *Server (or a resolver whose Server() method returns one) when loading persisted results.","Implement the server-extraction interface on the custom TypeResolver, returning the underlying *Server.","Check for nil-Server embedding — make sure the Server field is initialized before LoadResultByResultID is called.","Audit code paths that substitute a test resolver into import/attach paths."],"exampleFix":"// before\ncache.LoadResultByResultID(ctx, session, testResolver, id)\n// after\ncache.LoadResultByResultID(ctx, session, dag, id) // dag is the initialized *dagql.Server","handlingStrategy":"validation","validationCode":"if dag == nil || dag.Server() == nil { return errors.New(\"resolver must expose a dagql server\") }","typeGuard":"func providesServer(r dagql.TypeResolver) bool {\n  s, ok := r.(interface{ Server() *dagql.Server })\n  return ok && s.Server() != nil\n}","tryCatchPattern":"res, err := cache.LoadResultByResultID(ctx, session, dag, id)\nif err != nil && strings.Contains(err.Error(), \"does not provide dagql server\") {\n  return fmt.Errorf(\"configure real *dagql.Server: %w\", err)\n}","preventionTips":["Always pass the live *dagql.Server into persistence load APIs","Never substitute test resolvers in production import paths","Initialize the Server field before any cache loads"],"tags":["dagql","cache","persistence","resolver-misconfiguration"],"backgroundTag":"resolver-missing-dagql-server","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"}