{"record":{"id":"4ec32e51f2c20260","repo":"dagger/dagger","slug":"evaluate-base-selector-w","errorCode":null,"errorMessage":"evaluate base selector: %w","messagePattern":"evaluate base selector: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/changeset.go","lineNumber":1636,"sourceCode":"\n// withGitMergeWorkspace sets up a workspace for git merge operations, runs the provided\n// function, then commits and returns the resulting directory.\nfunc withGitMergeWorkspace(ctx context.Context, base dagql.ObjectResult[*Directory], description string, fn func(ws *gitMergeWorkspace) error) (*Directory, error) {\n\tcache, err := dagql.EngineCache(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := cache.Evaluate(ctx, base); err != nil {\n\t\treturn nil, fmt.Errorf(\"evaluate base: %w\", err)\n\t}\n\n\tbaseRef, err := base.Self().Snapshot.GetOrEval(ctx, base.Result)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"evaluate base: %w\", err)\n\t}\n\tbaseSelector, err := base.Self().Dir.GetOrEval(ctx, base.Result)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"evaluate base selector: %w\", err)\n\t}\n\n\tquery, err := CurrentQuery(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnewRef, err := query.SnapshotManager().New(ctx, baseRef,\n\t\tbkcache.WithRecordType(bkclient.UsageRecordTypeRegular),\n\t\tbkcache.WithDescription(description))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = MountRef(ctx, newRef, func(root string, _ *mount.Mount) error {\n\t\tworkDir, err := containerdfs.RootPath(root, baseSelector)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":1618,"sourceCodeEnd":1654,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/changeset.go#L1618-L1654","documentation":"In withGitMergeWorkspace (core/changeset.go:1636), this wraps failure of base.Self().Dir.GetOrEval — resolving the base directory's subpath selector (the path within the directory the merge should operate on). If the selector cannot be evaluated (invalid path, wrong accessor state), the engine cannot locate the working directory inside the snapshot and returns 'evaluate base selector:'.","triggerScenarios":"Passing a Directory whose Dir subpath accessor fails to evaluate into a merge: typically a .Directory(subpath) selection on a nonexistent path, or an accessor that was never set/evaluated before the merge call.","commonSituations":"Typo or wrong subpath passed to .Directory(); operating on a directory derived from a failed build; engine version mismatch where accessor state differs.","solutions":["Check the subpath argument passed to .Directory()/directory selection — confirm it exists in the base directory (e.g. via `dagger query` or directory.entries).","Evaluate the base directory and its selected subpath separately before the merge to reproduce/see the underlying error.","Fix the upstream pipeline producing the base directory if the selector fails because content is missing.","Upgrade the Dagger CLI/engine to matching versions if this appears after a version change."],"exampleFix":"// before\ndir := client.Directory().Directory(\"src\") // path may not exist\nmerged := dir.WithChangeset(...)\n\n// after\nentries, _ := client.Directory().Entries()\n// verify \"src\" exists in entries before selecting\ndir := client.Directory().Directory(\"src\")","handlingStrategy":"validation","validationCode":"// Confirm the selected subpath exists before merging\nentries, err := baseDir.Entries(ctx)\nif err != nil {\n    return err\n}\nif !slices.Contains(entries, \"src\") {\n    return fmt.Errorf(\"subpath %q missing from base directory\", \"src\")\n}","typeGuard":"func isSelectorErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"evaluate base selector:\")\n}","tryCatchPattern":"merged, err := mergeInto(base.Subdir(\"src\"), cs)\nif err != nil && isSelectorErr(err) {\n    return fmt.Errorf(\"check the subpath passed to .Directory(): %w\", err)\n}","preventionTips":["Always verify subpaths exist via directory.entries before selecting them","Avoid string-built paths; use constants or schema-validated paths","Test the base-directory construction pipeline independently of the merge","Keep CLI and engine versions aligned to avoid accessor state mismatches"],"tags":["directory-selector","evaluation","subpath"],"backgroundTag":"directory-selector-evaluation-failed","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"}