{"record":{"id":"50f34724d53272d5","repo":"GoogleContainerTools/skaffold","slug":"could-not-find-latest-tag-for-image-s-in-builds","errorCode":null,"errorMessage":"could not find latest tag for image %s in builds: %v","messagePattern":"could not find latest tag for image (.+?) in builds: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/sync/sync.go","lineNumber":67,"sourceCode":"var (\n\tWorkingDir = docker.RetrieveWorkingDir\n\tLabels     = docker.RetrieveLabels\n\tSyncMap    = syncMapForArtifact\n)\n\nfunc NewItem(ctx context.Context, a *latest.Artifact, e filemon.Events, builds []graph.Artifact, cfg docker.Config, dependentArtifactsCount int) (*Item, error) {\n\tif !e.HasChanged() || a.Sync == nil {\n\t\treturn nil, nil\n\t}\n\n\tif dependentArtifactsCount > 0 {\n\t\tlog.Entry(ctx).Warnf(\"Ignoring sync rules for image %q as it is being used as a required artifact for other images.\", a.ImageName)\n\t\treturn nil, nil\n\t}\n\n\ttag := latestTag(a.ImageName, builds)\n\tif tag == \"\" {\n\t\treturn nil, fmt.Errorf(\"could not find latest tag for image %s in builds: %v\", a.ImageName, builds)\n\t}\n\n\tswitch {\n\tcase len(a.Sync.Manual) > 0:\n\t\treturn syncItem(ctx, a, tag, e, a.Sync.Manual, cfg)\n\n\tcase a.Sync.Auto != nil:\n\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) {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/sync/sync.go#L49-L85","documentation":"`NewItem` calls `latestTag(a.ImageName, builds)` to find the most recent build tag for the image being synced, and errors when no tag is found. It means the image being file-synced has no matching entry in the current builds list, so skaffold cannot determine which container/tag to sync into.","triggerScenarios":"Calling `NewItem` (during `skaffold dev` file change handling) with an artifact whose ImageName is absent from the `builds` slice — e.g. the artifact was never built, the image name was renamed in skaffold.yaml without rebuilding, or builds was passed empty.","commonSituations":"Editing `imageName` in skaffold.yaml mid-session so the saved file syncs an artifact that was built under a different name; dev session started with a profile that skips building this artifact; stale dev session after build cache was cleared; image built by another pipeline (e.g. CI) so no local build record exists.","solutions":["Rebuild the artifact (restart `skaffold dev` or force a build) so its tag is present in the builds list.","Ensure the artifact's ImageName in skaffold.yaml exactly matches the name used in builds (no typos/renames mid-session).","If the image is built externally, make sure the builds list passed to NewItem includes its tag.","Check active profiles don't exclude this artifact from the build phase."],"exampleFix":"// before (renamed image mid-session)\nbuild.artifacts: [{image: {imageName: \"web-v2\"}}] // builds contains \"web\"\n// after\nskaffold build && skaffold dev // rebuild so \"web-v2\" tag exists in builds","handlingStrategy":"validation","validationCode":"func hasTag(builds []build.Artifact, image string) bool {\n  for _, b := range builds {\n    if b.ImageName == image && b.Tag != \"\" { return true }\n  }\n  return false\n}\n// only start dev / sync if hasTag(builds, artifact.ImageName)","typeGuard":null,"tryCatchPattern":"item, err := sync.NewItem(ctx, artifact, events, builds, cfg)\nif err != nil {\n  if strings.Contains(err.Error(), \"could not find latest tag\") {\n    log.Printf(\"image %s has no build yet; forcing build before sync\", artifact.ImageName)\n    return forceBuild(artifact)\n  }\n  return err\n}","preventionTips":["Always build before enabling file sync (skaffold run/dev builds first by default).","Keep image names stable in skaffold.yaml; avoid renaming mid-session.","Check active profiles don't exclude the artifact from the build.","Pass the complete builds list to NewItem, including externally built images."],"tags":["file-sync","build","configuration","go"],"backgroundTag":"missing-image-tag","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"}