{"record":{"id":"35ad11c594dfcd88","repo":"docker/cli","slug":"refusing-to-amend-an-existing-manifest-list-with-n","errorCode":null,"errorMessage":"refusing to amend an existing manifest list with no --amend flag","messagePattern":"refusing to amend an existing manifest list with no --amend flag","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/manifest/create_list.go","lineNumber":53,"sourceCode":"\treturn cmd\n}\n\nfunc createManifestList(ctx context.Context, dockerCLI command.Cli, args []string, opts createOpts) error {\n\tnewRef := args[0]\n\ttargetRef, err := normalizeReference(newRef)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing name for manifest list %s: %w\", newRef, err)\n\t}\n\n\tmanifestStore := newManifestStore(dockerCLI)\n\t_, err = manifestStore.GetList(targetRef)\n\tswitch {\n\tcase errdefs.IsNotFound(err):\n\t\t// New manifest list\n\tcase err != nil:\n\t\treturn err\n\tcase !opts.amend:\n\t\treturn errors.New(\"refusing to amend an existing manifest list with no --amend flag\")\n\t}\n\n\t// Now create the local manifest list transaction by looking up the manifest schemas\n\t// for the constituent images:\n\tmanifests := args[1:]\n\tfor _, manifestRef := range manifests {\n\t\tnamedRef, err := normalizeReference(manifestRef)\n\t\tif err != nil {\n\t\t\t// TODO: wrap error?\n\t\t\treturn err\n\t\t}\n\n\t\tmanifest, err := getManifest(ctx, dockerCLI, targetRef, namedRef, opts.insecure)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := manifestStore.Save(targetRef, namedRef, manifest); err != nil {\n\t\t\treturn err","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/manifest/create_list.go#L35-L71","documentation":"createManifestList() looks up the target ref in the local manifest store; if a list already exists and the user did not pass --amend/-a, it refuses to silently clobber an in-progress manifest list. errdefs.IsNotFound proceeds (new list); any other existing-list case requires --amend.","triggerScenarios":"Running `docker manifest create <list> ...` a second time after the list was already created locally, without --amend.","commonSituations":"Retrying a partially-built manifest list; CI re-running a create step; iterating on a manifest assembly.","solutions":["Add --amend/-a to append to the existing list","Remove the existing local list first and recreate it cleanly","Check for an existing list before deciding to create vs amend"],"exampleFix":"// before\ndocker manifest create myrepo/mylist:latest img1 img2\n// after\ndocker manifest create --amend myrepo/mylist:latest img1 img2","handlingStrategy":"try-catch","validationCode":"manifestStore := newManifestStore(dockerCLI)\nif _, err := manifestStore.GetList(targetRef); err == nil {\n    // list exists — caller must decide: amend or recreate\n    if !opts.amend { opts.amend = true /* or abort */ }\n}","typeGuard":"func listExists(store ManifestStore, ref string) bool {\n    _, err := store.GetList(ref)\n    return err == nil\n}","tryCatchPattern":"err := createManifestList(ctx, cli, args, opts)\nif err != nil && strings.Contains(err.Error(), \"refusing to amend\") {\n    // retry with --amend, or remove the list first then recreate\n    opts.amend = true\n    err = createManifestList(ctx, cli, args, opts)\n}\nreturn err","preventionTips":["Pass --amend/-a when re-running create against an existing list","Check GetList() first to choose create vs amend programmatically","In CI, either use --amend or remove the local list before re-running"],"tags":["manifest","registry","cli","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}