{"record":{"id":"04632ec2d719aad2","repo":"kubernetes/kops","slug":"must-set-output-flag-yaml-or-json","errorCode":null,"errorMessage":"must set output flag; yaml or json","messagePattern":"must set output flag; yaml or json","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_instancegroup.go","lineNumber":233,"sourceCode":"\n\tig, err = cloudup.PopulateInstanceGroupSpec(cluster, ig, cloud, channel)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tig.AddInstanceGroupNodeLabel()\n\tif cluster.GetCloudProvider() == kopsapi.CloudProviderGCE {\n\t\tif len(ig.Spec.Zones) == 0 {\n\t\t\treturn fmt.Errorf(\"zone flag is required for GCE clusters\")\n\t\t}\n\t\tfmt.Println(\"detected a GCE cluster; labeling nodes to receive metadata-proxy.\")\n\t\tig.Spec.NodeLabels[\"cloud.google.com/metadata-proxy-ready\"] = \"true\"\n\t}\n\n\tif options.DryRun {\n\n\t\tif options.Output == \"\" {\n\t\t\treturn fmt.Errorf(\"must set output flag; yaml or json\")\n\t\t}\n\n\t\t// Cluster name is not populated, and we need it\n\t\tig.ObjectMeta.Labels = make(map[string]string)\n\t\tig.ObjectMeta.Labels[kopsapi.LabelClusterName] = cluster.ObjectMeta.Name\n\n\t\tswitch options.Output {\n\t\tcase OutputYaml:\n\t\t\tif err := fullOutputYAML(out, ig); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error writing cluster yaml to stdout: %v\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\tcase OutputJSON:\n\t\t\tif err := fullOutputJSON(out, true, ig); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error writing cluster json to stdout: %v\", err)\n\t\t\t}\n\t\t\treturn nil\n\t\tdefault:","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_instancegroup.go#L215-L251","documentation":"In --dry-run mode, RunCreateInstanceGroup must serialize the IG to a file-like output, but the --output flag was empty so the format (yaml or json) is unknown. Only the dry-run path requires this flag.","triggerScenarios":"Thrown at cmd/kops/create_instancegroup.go:233 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add --output yaml or --output json to the dry-run command","Omit --dry-run if you want the IG created directly in the state store"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}