{"record":{"id":"cd5304c14a78dc33","repo":"GoogleContainerTools/skaffold","slug":"intersecting-sync-map-and-deleted-files-w","errorCode":null,"errorMessage":"intersecting sync map and deleted files: %w","messagePattern":"intersecting sync map and deleted files: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/sync/sync.go","lineNumber":98,"sourceCode":"\tdefault:\n\t\treturn nil, nil\n\t}\n}\n\nfunc syncItem(ctx context.Context, a *latest.Artifact, tag string, e filemon.Events, syncRules []*latest.SyncRule, cfg docker.Config) (*Item, error) {\n\tcontainerWd, err := WorkingDir(ctx, tag, cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"retrieving working dir for %q: %w\", tag, err)\n\t}\n\n\ttoCopy, err := intersect(ctx, a.Workspace, containerWd, syncRules, append(e.Added, e.Modified...))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"intersecting sync map and added, modified files: %w\", err)\n\t}\n\n\ttoDelete, err := intersect(ctx, a.Workspace, containerWd, syncRules, e.Deleted)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"intersecting sync map and deleted files: %w\", err)\n\t}\n\n\t// Something went wrong, don't sync, rebuild.\n\tif toCopy == nil || toDelete == nil {\n\t\treturn nil, nil\n\t}\n\n\treturn &Item{Image: tag, Artifact: a, Copy: toCopy, Delete: toDelete}, nil\n}\n\nfunc inferredSyncItem(ctx context.Context, a *latest.Artifact, tag string, e filemon.Events, cfg docker.Config) (*Item, error) {\n\t// the ko builder doesn't need or use a sync map\n\tif a.KoArtifact != nil {\n\t\tlog.Entry(ctx).Debugf(\"ko inferred sync %+v\", e)\n\t\ttoCopy, toDelete, err := kosync.Infer(ctx, a, e)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/sync/sync.go#L80-L116","documentation":"`syncItem` wraps failures from `intersect` when computing deletions: deleted workspace files must be matched against sync rules to know which container paths to remove. Failure here means the delete-side sync map could not be computed, so the sync Item is aborted (the caller rebuilds instead of syncing).","triggerScenarios":"Calling `syncItem` with `e.Deleted` entries whose paths cannot be relativized against `a.Workspace` or matched to sync rules — e.g. the file was already removed so rel/exists checks fail, or paths point outside the workspace.","commonSituations":"Deleting files via git operations (checkout/branch switch) that batch-delete paths the watcher reports oddly; deleting symlinked or generated files; workspace path changed between builds so old paths no longer relativize; case-sensitive vs case-insensitive filesystem mismatches.","solutions":["Verify deleted paths were inside the artifact workspace and the workspace config hasn't changed.","Restart `skaffold dev` to reset watcher/sync state after branch switches or bulk deletions.","Force a full rebuild (touch a source file or use --force) so stale delete events are discarded.","Check sync rules (manual/infer) in skaffold.yaml match the file locations being deleted."],"exampleFix":"// before\ngit checkout other-branch // mass delete confuses sync\n// after\n# stop dev, switch branch, restart\nskaffold dev","handlingStrategy":"fallback","validationCode":"wd, _ := filepath.Abs(artifact.Workspace)\nfor _, f := range events.Deleted {\n  abs, _ := filepath.Abs(f)\n  if rel, err := filepath.Rel(wd, abs); err != nil || strings.HasPrefix(rel, \"..\") {\n    return triggerRebuild(artifact) // deletions outside workspace: rebuild instead\n  }\n}","typeGuard":null,"tryCatchPattern":"if err := runSync(...); err != nil {\n  if strings.Contains(err.Error(), \"intersecting sync map and deleted files\") {\n    log.Printf(\"delete sync failed (%v); falling back to rebuild\", err)\n    return triggerRebuild(artifact)\n  }\n  return err\n}","preventionTips":["Restart skaffold dev after git branch switches that batch-delete files.","Only delete files within the configured artifact workspace during dev.","Avoid deleting generated/symlinked files that the watcher tracks.","Treat delete-sync failures as rebuild signals rather than retrying."],"tags":["file-sync","filesystem","paths","go"],"backgroundTag":"file-path-outside-workspace","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}