GoogleContainerTools/skaffold · error

intersecting sync map and added, modified files: %w

Error message

intersecting sync map and added, modified files: %w

What it means

`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.

Source

Thrown at pkg/skaffold/sync/sync.go:93

		return autoSyncItem(ctx, a, tag, e, cfg)

	case len(a.Sync.Infer) > 0:
		return inferredSyncItem(ctx, a, tag, e, cfg)

	default:
		return nil, nil
	}
}

func syncItem(ctx context.Context, a *latest.Artifact, tag string, e filemon.Events, syncRules []*latest.SyncRule, cfg docker.Config) (*Item, error) {
	containerWd, err := WorkingDir(ctx, tag, cfg)
	if err != nil {
		return nil, fmt.Errorf("retrieving working dir for %q: %w", tag, err)
	}

	toCopy, err := intersect(ctx, a.Workspace, containerWd, syncRules, append(e.Added, e.Modified...))
	if err != nil {
		return nil, fmt.Errorf("intersecting sync map and added, modified files: %w", err)
	}

	toDelete, err := intersect(ctx, a.Workspace, containerWd, syncRules, e.Deleted)
	if err != nil {
		return nil, fmt.Errorf("intersecting sync map and deleted files: %w", err)
	}

	// Something went wrong, don't sync, rebuild.
	if toCopy == nil || toDelete == nil {
		return nil, nil
	}

	return &Item{Image: tag, Artifact: a, Copy: toCopy, Delete: toDelete}, nil
}

func inferredSyncItem(ctx context.Context, a *latest.Artifact, tag string, e filemon.Events, cfg docker.Config) (*Item, error) {
	// the ko builder doesn't need or use a sync map
	if a.KoArtifact != nil {

View on GitHub (pinned to a1189de023)

Solutions

  1. Ensure edited files live inside the artifact's `workspace` directory (follow symlinks and edit real files).
  2. Verify the `workspace` path in skaffold.yaml matches the actual project layout (absolute/relative, no typos).
  3. Re-run dev to refresh watcher state and get consistent path events.
  4. If paths are legitimately external, move them into the workspace or add explicit manual sync rules.

Example fix

// before
artifacts:
  - image: app
    workspace: ../shared-lib // files edited outside workspace
// after
artifacts:
  - image: app
    workspace: . // workspace covers all synced source files
Defensive patterns

Strategy: validation

Validate before calling

wd, _ := filepath.Abs(artifact.Workspace)
for _, f := range append(events.Added, events.Modified...) {
  abs, _ := filepath.Abs(f)
  if rel, err := filepath.Rel(wd, abs); err != nil || strings.HasPrefix(rel, "..") {
    return fmt.Errorf("file %q is outside workspace %q; rebuild instead of sync", f, wd)
  }
}

Try / catch

if err := runSync(...); err != nil {
  if strings.Contains(err.Error(), "intersecting sync map") {
    log.Printf("sync map computation failed (%v); forcing rebuild", err)
    return triggerRebuild(artifact)
  }
  return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/694100dc0cf99427. Report an issue: GitHub.