{"record":{"id":"484b581bc41ca8e0","repo":"slimtoolkit/slim","slug":"must-have-two-image-references","errorCode":null,"errorMessage":"must have two image references","messagePattern":"must have two image references","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/merge/cli.go","lineNumber":75,"sourceCode":"type CommandParams struct {\n\tFirstImage           string   `json:\"first_image\"`\n\tLastImage            string   `json:\"last_image\"`\n\tUseLastImageMetadata bool     `json:\"use_last_image_metadata\"`\n\tOutputTags           []string `json:\"output_tags\"`\n}\n\nfunc CommandFlagValues(xc *app.ExecutionContext, ctx *cli.Context) (*CommandParams, error) {\n\tvalues := &CommandParams{\n\t\tUseLastImageMetadata: ctx.Bool(FlagUseLastImageMetadata),\n\t\tOutputTags:           ctx.StringSlice(FlagTag),\n\t}\n\n\timages := ctx.StringSlice(FlagImage)\n\tif len(images) > 0 {\n\t\tif len(images) < 2 {\n\t\t\txc.Out.Error(\"param.image\", \"must have two image references\")\n\t\t\tcli.ShowCommandHelp(ctx, Name)\n\t\t\treturn nil, fmt.Errorf(\"must have two image references\")\n\t\t}\n\n\t\tvalues.FirstImage = images[0]\n\t\tvalues.LastImage = images[1]\n\t}\n\n\tif ctx.Args().Len() > 0 {\n\t\tif ctx.Args().Len() < 2 {\n\t\t\txc.Out.Error(\"param.image\", \"must have two image references\")\n\t\t\tcli.ShowCommandHelp(ctx, Name)\n\t\t\treturn nil, fmt.Errorf(\"must have two image references\")\n\t\t}\n\n\t\tvalues.FirstImage = ctx.Args().Get(0)\n\t\tvalues.LastImage = ctx.Args().Get(1)\n\t}\n\n\tif values.FirstImage == \"\" || values.LastImage == \"\" {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/merge/cli.go#L57-L93","documentation":"The merge command combines two container images into one. When the --image flag is used, CommandFlagValues requires exactly two values; fewer than two fails with 'must have two image references'. The error is printed as a param.image output and command help is shown.","triggerScenarios":"Running `slim merge --image <one-image>` (a single --image value, or a repeated flag count < 2) before flag parsing completes in merge/cli.go CommandFlagValues.","commonSituations":"Providing only one --image flag; quoting mistakes causing the second image to be swallowed into one argument; forgetting that positional args and --image flags are separate mechanisms; shell glob not expanding.","solutions":["Pass two image references: `slim merge --image image1 --image image2`.","Or pass them as positional arguments: `slim merge image1 image2`.","Quote image references containing tags/digests so the shell doesn't split them.","Check the printed command help (shown automatically) for the expected flag usage."],"exampleFix":"// before\nslim merge --image myrepo/app:1.0\n// after\nslim merge --image myrepo/app:1.0 --image myrepo/app:2.0","handlingStrategy":"validation","validationCode":"images=()\nwhile IFS= read -r x; do images+=(\"$x\"); done < <(parse_flags)  # collect --image values\n[ \"${#images[@]}\" -eq 2 ] || { echo \"merge needs exactly 2 images\"; exit 2; }","typeGuard":null,"tryCatchPattern":"if err := runMerge(args); err != nil && strings.Contains(err.Error(), \"must have two image references\") {\n    // print usage and exit with input-validation code\n}","preventionTips":["Always pass --image exactly twice (or two positional args)","Quote image refs with tags/digests","Validate arg counts in CI wrapper scripts before invoking slim"],"tags":["cli","parameters","merge"],"backgroundTag":"missing-required-argument","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}