{"record":{"id":"12aa05be733b6372","repo":"dagger/dagger","slug":"merge-dropped-declared-changes-s-engine-bug-th","errorCode":null,"errorMessage":"merge dropped declared changes: %s (engine bug: the merge workspace lost applied content)","messagePattern":"merge dropped declared changes: (.+?) \\(engine bug: the merge workspace lost applied content\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/changeset.go","lineNumber":1614,"sourceCode":"\t\t}\n\t\tpaths := content.paths.withoutGitMeta()\n\t\tfor _, p := range slices.Concat(paths.Added, paths.Modified) {\n\t\t\tif strings.HasSuffix(p, \"/\") {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfull, err := RootPathWithoutFinalSymlink(ws.root, path.Join(ws.dir, p))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif _, err := os.Lstat(full); errors.Is(err, os.ErrNotExist) {\n\t\t\t\tmissing = append(missing, p)\n\t\t\t} else if err != nil {\n\t\t\t\treturn TrimErrPathPrefix(err, ws.root)\n\t\t\t}\n\t\t}\n\t}\n\tif len(missing) > 0 {\n\t\treturn fmt.Errorf(\"merge dropped declared changes: %s (engine bug: the merge workspace lost applied content)\", strings.Join(missing, \", \"))\n\t}\n\treturn nil\n}\n\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)","sourceCodeStart":1596,"sourceCodeEnd":1632,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/changeset.go#L1596-L1632","documentation":"This error is a self-check inside Dagger's git-based changeset merge (verifyMergedPaths in core/changeset.go:1614). After a conflict-free git merge in a temporary repository, the engine verifies that every file path the changesets declared as added or modified actually exists in the merged worktree; if any are missing it reports this error because there is no legitimate way a conflict-free merge should drop declared content. It signals an engine-internal bug (e.g. a stale .git/HEAD redirecting the ours commit so the merge silently resolves to one side), not user error.","triggerScenarios":"Calling Directory.withChangeset / merge APIs (gitMergeChangesets) where the merge reports success and conflicts are empty, but files the changeset declared Added or Modified are absent from the merged worktree during os.Lstat in verifyMergedPaths.","commonSituations":"Encountered during Dagger engine upgrades or regressions in the temporary merge-repository plumbing; historically caused by stale .git/HEAD from a changeset diff pointing the 'ours' branch at the wrong commit, or mtime/size-identical edits being skipped by git add (core.checkStat=minimal). Users see it only as an opaque engine bug report.","solutions":["Upgrade or downgrade the Dagger engine version — this indicates an engine bug; check dagger.VERSION changelog and GitHub issues for 'merge dropped declared changes' and report with a repro if new.","Simplify the merge: verify which declared paths are listed in the error and check whether those files are identical in size/mtime on both sides (deduped snapshots can confuse git stat).","As a workaround, perform the merge manually by exporting both directories and merging outside the engine (e.g. via git in a container) until the engine fix lands.","Retry the operation; if a stale temp workspace was involved, a fresh engine session may avoid the corrupted state."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-validate the changeset paths you expect to survive the merge\nfor _, p := range append(changeset.Added, changeset.Modified...) {\n    if strings.HasSuffix(p, \"/\") { continue }\n    if _, err := os.Stat(path.Join(baseDirPath, p)); errors.Is(err, os.ErrNotExist) {\n        return fmt.Errorf(\"path %q not present in base; merge cannot apply it\", p)\n    }\n}","typeGuard":"func isMergeDroppedChangesErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"merge dropped declared changes\")\n}","tryCatchPattern":"merged, err := dir.WithChangeset(cs).Directory(ctx)\nif err != nil {\n    if isMergeDroppedChangesErr(err) {\n        // engine bug: report to Dagger with repro; do not retry blindly\n        log.Fatalf(\"engine integrity failure, please report: %v\", err)\n    }\n    return err\n}","preventionTips":["Keep the Dagger engine and CLI versions in sync and up to date","Avoid depending on same-size/same-mtime edits when layering changesets","Pin a known-good engine version; watch Dagger releases for merge-related fixes","If triggered, file a minimal repro — this error is designed to surface engine bugs, not user mistakes"],"tags":["engine-bug","git-merge","integrity-check"],"backgroundTag":"merge-dropped-declared-changes","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"}