{"record":{"id":"84551500143f4a8d","repo":"GoogleContainerTools/skaffold","slug":"exec-requires-exactly-one-action-to-execute","errorCode":null,"errorMessage":"`exec` requires exactly one action to execute","messagePattern":"`exec` requires exactly one action to execute","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/skaffold/app/cmd/exec.go","lineNumber":46,"sourceCode":"\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/output/log\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/runner\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest\"\n\t\"github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util\"\n)\n\n// NewCmdExec describes the CLI command to execute a custom action.\nfunc NewCmdExec() *cobra.Command {\n\treturn NewCmd(\"exec\").\n\t\tWithDescription(\"Execute a custom action\").\n\t\tWithExample(\"Execute a defined action\", \"exec <action-name>\").\n\t\tWithExample(\"Execute a defined action that uses an image built from Skaffold. First, build the images\", \"build --file-output=build.json\").\n\t\tWithExample(\"Then use the built artifacts\", \"exec <action-name> --build-artifacts=build.json\").\n\t\tWithCommonFlags().\n\t\tWithHouseKeepingMessages().\n\t\tWithArgs(func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) != 1 {\n\t\t\t\tlog.Entry(context.TODO()).Errorf(\"`exec` requires exactly one action to execute\")\n\t\t\t\treturn errors.New(\"`exec` requires exactly one action to execute\")\n\t\t\t}\n\t\t\treturn nil\n\t\t}, doExec)\n}\n\nfunc doExec(ctx context.Context, out io.Writer, args []string) error {\n\treturn withRunner(ctx, out, func(r runner.Runner, configs []util.VersionedConfig) error {\n\t\tbuildArtifacts, err := getBuildArtifactsAndSetTagsForAction(configs, r.ApplyDefaultRepo, args[0])\n\t\tif err != nil {\n\t\t\ttips.PrintUseBuildAndExec(out)\n\t\t\treturn err\n\t\t}\n\t\treturn r.Exec(ctx, out, buildArtifacts, args[0])\n\t})\n}\n\nfunc getBuildArtifactsAndSetTagsForAction(configs []util.VersionedConfig, defaulterFn DefaultRepoFn, action string) ([]graph.Artifact, error) {\n\timgs := getActionImgs(action, configs)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/cmd/skaffold/app/cmd/exec.go#L28-L64","documentation":"Skaffold's `exec` command runs exactly one named action defined in skaffold.yaml. The Args validator requires len(args) == 1; zero or multiple arguments produce this error. The message is also logged via log.Entry before being returned.","triggerScenarios":"Running `skaffold exec` with no action name, or `skaffold exec action-a action-b` with more than one positional argument. Also triggered when a quoted action name accidentally splits into multiple args.","commonSituations":"Forgetting the action name after flags (`exec --build-artifacts=build.json`); passing extra tokens like `exec run my-action`; shell word-splitting on an unquoted variable.","solutions":["Invoke with exactly one action name: `skaffold exec <action-name>`","Quote names containing spaces: `skaffold exec \"my action\"`","List available actions in skaffold.yaml (`actions:` section) and pick one"],"exampleFix":"// before\nskaffold exec --build-artifacts=build.json\n// after\nskaffold exec build-and-test --build-artifacts=build.json","handlingStrategy":"validation","validationCode":"ACTION=$(echo \"$ACTION\" | xargs) # normalize; then:\n[ $# -eq 1 ] || { echo \"usage: skaffold exec <action-name>\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote action names so shell splitting keeps args count at exactly 1","Verify the action exists in the `actions:` section of skaffold.yaml","Place flags before the single positional argument"],"tags":["cli","argument-validation","skaffold"],"backgroundTag":"missing-required-argument","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"}