{"record":{"id":"243370ddef47c0de","repo":"kubernetes/kops","slug":"unable-to-execute-dry-run-without-setting-outp","errorCode":null,"errorMessage":"unable to execute --dry-run without setting --output","messagePattern":"unable to execute --dry-run without setting --output","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_cluster.go","lineNumber":542,"sourceCode":"\tctx, span := tracer.Start(ctx, \"RunCreateCluster\")\n\tdefer span.End()\n\n\tisDryrun := false\n\t// direct requires --yes (others do not, because they don't make changes)\n\ttargetName := c.Target\n\tif c.Target == cloudup.TargetDirect {\n\t\tif !c.Yes {\n\t\t\tisDryrun = true\n\t\t\ttargetName = cloudup.TargetDryRun\n\t\t}\n\t}\n\tif c.Target == cloudup.TargetDryRun {\n\t\tisDryrun = true\n\t\ttargetName = cloudup.TargetDryRun\n\t}\n\n\tif c.DryRun && c.Output == \"\" {\n\t\treturn fmt.Errorf(\"unable to execute --dry-run without setting --output\")\n\t}\n\n\t// TODO: Reuse rootCommand stateStore logic?\n\n\tif c.OutDir == \"\" {\n\t\tif c.Target == cloudup.TargetTerraform {\n\t\t\tc.OutDir = \"out/terraform\"\n\t\t} else {\n\t\t\tc.OutDir = \"out\"\n\t\t}\n\t}\n\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif c.ClusterName == \"\" {","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_cluster.go#L524-L560","documentation":"RunCreateCluster rejects --dry-run when --output is not set, because a dry run renders the manifests to the chosen output format (yaml/json) and needs a destination format. This is an explicit argument-consistency validation in the CLI.","triggerScenarios":"Invoking `kops create cluster --dry-run` without also passing `--output yaml` (or json).","commonSituations":"Scripting dry-run cluster creation to preview manifests but forgetting the output flag; copying old command lines where --output was dropped.","solutions":["Add --output yaml (or json) alongside --dry-run","If you intend to actually create the cluster, remove --dry-run instead","Note: --out (target directory for terraform) is not the same as --output"],"exampleFix":"// before\nkops create cluster mycluster.example.com --dry-run\n// after\nkops create cluster mycluster.example.com --dry-run --output yaml","handlingStrategy":"validation","validationCode":"if dryRun && outputFlag == \"\" {\n\t// fix before invoking\n\toutputFlag = \"yaml\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair --dry-run with --output yaml|json","Remember --out (directory) differs from --output (format)","Add the pair as a single option in wrapper scripts"],"tags":["cli","validation","dry-run"],"backgroundTag":"missing-required-flag","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}