{"record":{"id":"694100dc0cf99427","repo":"GoogleContainerTools/skaffold","slug":"intersecting-sync-map-and-added-modified-files","errorCode":null,"errorMessage":"intersecting sync map and added, modified files: %w","messagePattern":"intersecting sync map and added, modified files: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/sync/sync.go","lineNumber":93,"sourceCode":"\t\treturn autoSyncItem(ctx, a, tag, e, cfg)\n\n\tcase len(a.Sync.Infer) > 0:\n\t\treturn inferredSyncItem(ctx, a, tag, e, cfg)\n\n\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 {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/sync/sync.go#L75-L111","documentation":"`syncItem` wraps failures from `intersect`, which maps added/modified files in the workspace to their destination paths in the container using the sync rules. The error means the sync map for added/modified files could not be computed (e.g. path/relpath computation or rule matching failed), so the sync Item can't be built and a rebuild is needed.","triggerScenarios":"Calling `syncItem` when files in `e.Added`/`e.Modified` cannot be made relative to the workspace (path outside workspace, symlinks escaping it, invalid paths), or when intersect's internal glob matching of sync rules fails.","commonSituations":"Editing files through symlinks that resolve outside a.Workspace; watcher events reporting paths with different casing or absolute prefix than Workspace; workspace path configured with a trailing slash or typo in skaffold.yaml; OS-specific path separator mismatches on Windows.","solutions":["Ensure edited files live inside the artifact's `workspace` directory (follow symlinks and edit real files).","Verify the `workspace` path in skaffold.yaml matches the actual project layout (absolute/relative, no typos).","Re-run dev to refresh watcher state and get consistent path events.","If paths are legitimately external, move them into the workspace or add explicit manual sync rules."],"exampleFix":"// before\nartifacts:\n  - image: app\n    workspace: ../shared-lib // files edited outside workspace\n// after\nartifacts:\n  - image: app\n    workspace: . // workspace covers all synced source files","handlingStrategy":"validation","validationCode":"wd, _ := filepath.Abs(artifact.Workspace)\nfor _, f := range append(events.Added, events.Modified...) {\n  abs, _ := filepath.Abs(f)\n  if rel, err := filepath.Rel(wd, abs); err != nil || strings.HasPrefix(rel, \"..\") {\n    return fmt.Errorf(\"file %q is outside workspace %q; rebuild instead of sync\", f, wd)\n  }\n}","typeGuard":null,"tryCatchPattern":"if err := runSync(...); err != nil {\n  if strings.Contains(err.Error(), \"intersecting sync map\") {\n    log.Printf(\"sync map computation failed (%v); forcing rebuild\", err)\n    return triggerRebuild(artifact)\n  }\n  return err\n}","preventionTips":["Edit source files inside the artifact workspace directory, not via external symlinks.","Keep the `workspace` value in skaffold.yaml accurate and free of typos/trailing slashes.","Restart dev after branch switches or bulk file operations to refresh watcher state.","Normalize paths (casing, separators) if developing on case-insensitive filesystems."],"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"}