{"record":{"id":"92d00b3099ca608f","repo":"dagger/dagger","slug":"load-persisted-s-snapshot-links-query-w","errorCode":null,"errorMessage":"load persisted %s snapshot links query: %w","messagePattern":"load persisted (.+?) snapshot links query: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/persisted_object.go","lineNumber":144,"sourceCode":"\t}\n\tlinks, err := cache.PersistedSnapshotLinksByResultID(ctx, resultID)\n\tif err != nil {\n\t\treturn dagql.PersistedSnapshotRefLink{}, fmt.Errorf(\"load persisted %s snapshot link: %w\", label, err)\n\t}\n\tfor _, link := range links {\n\t\tif link.Role == role {\n\t\t\treturn link, nil\n\t\t}\n\t}\n\treturn dagql.PersistedSnapshotRefLink{}, fmt.Errorf(\"missing persisted %s snapshot link role %q for result %d\", label, role, resultID)\n}\n\nfunc loadPersistedSnapshotLinksByResultID(ctx context.Context, dag *dagql.Server, resultID uint64, label string) ([]dagql.PersistedSnapshotRefLink, error) {\n\tif resultID == 0 {\n\t\treturn nil, fmt.Errorf(\"load persisted %s snapshot links: zero result ID\", label)\n\t}\n\tif _, err := persistedDecodeQuery(dag); err != nil {\n\t\treturn nil, fmt.Errorf(\"load persisted %s snapshot links query: %w\", label, err)\n\t}\n\tcache, err := dagql.EngineCache(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"load persisted %s snapshot links cache: %w\", label, err)\n\t}\n\tlinks, err := cache.PersistedSnapshotLinksByResultID(ctx, resultID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"load persisted %s snapshot links: %w\", label, err)\n\t}\n\treturn links, nil\n}\n\nfunc loadPersistedImmutableSnapshotByResultID(ctx context.Context, dag *dagql.Server, resultID uint64, label, role string) (bkcache.ImmutableRef, error) {\n\tlink, err := loadPersistedSnapshotLinkByResultID(ctx, dag, resultID, label, role)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tquery, err := persistedDecodeQuery(dag)","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/persisted_object.go#L126-L162","documentation":"Wraps failures from persistedDecodeQuery, which extracts the *Query from the dagql server's root object. This error means the dagql server passed to DecodePersistedObject is nil, has a nil root, or its root is not a *Query, so persisted snapshot links cannot be loaded.","triggerScenarios":"loadPersistedSnapshotLinksByResultID is called (via DecodePersistedObject) with a dag server whose root object was not constructed as *Query — e.g. a test server rooted at a different object, or a nil server passed in.","commonSituations":"Tests spinning up a dagql.Server with a custom root type; calling decode helpers before the engine finishes initializing the root query; refactoring that changed the root object type.","solutions":["Ensure the dagql.Server passed to decode functions was created with the engine's *Query as its root object.","Check for nil before calling: verify dag and dag.Root() are non-nil.","If running in a test harness, construct the server the same way the engine does (root *Query) instead of a stub."],"exampleFix":"// before\nsrv := dagql.NewServer(myCustomRoot{}) // root is not *Query\nobj, err := DecodePersistedObject(ctx, srv, payload)\n// after\nsrv := dagql.NewServer(query) // query is *core.Query\nobj, err := DecodePersistedObject(ctx, srv, payload)","handlingStrategy":"try-catch","validationCode":"if dag == nil || dag.Root() == nil {\n    return fmt.Errorf(\"dagql server not initialized\")\n}","typeGuard":"if q, ok := dagql.UnwrapAs[*core.Query](dag.Root()); ok {\n    // root is a *Query, safe to decode\n}","tryCatchPattern":"obj, err := DecodePersistedObject(ctx, dag, payload)\nif err != nil && strings.Contains(err.Error(), \"persisted decode query\") {\n    // server root is not *Query; re-init server with Query root\n}","preventionTips":["Construct dagql.Server with the engine's *Query as root.","Nil-check the server before decode calls.","Keep test harnesses rooted with *core.Query."],"tags":["persistence","initialization","dagger"],"backgroundTag":"missing-query-root","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"}