{"record":{"id":"b5d7bbcdc11ffa78","repo":"hashicorp/terraform","slug":"raw-output-format-is-only-supported-for-single-out","errorCode":null,"errorMessage":"Raw output format is only supported for single outputs","messagePattern":"Raw output format is only supported for single outputs","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/views/output.go","lineNumber":124,"sourceCode":"// output values directly and without quotes or other formatting. This is\n// intended for use in shell scripting or other environments where the exact\n// type of an output value is not important.\ntype OutputRaw struct {\n\tview *View\n}\n\nvar _ Output = (*OutputRaw)(nil)\n\nfunc (v *OutputRaw) Output(name string, outputs map[string]*states.OutputValue) tfdiags.Diagnostics {\n\tvar diags tfdiags.Diagnostics\n\n\tif len(outputs) == 0 {\n\t\tdiags = diags.Append(noOutputsWarning())\n\t\treturn diags\n\t}\n\n\tif name == \"\" {\n\t\tdiags = diags.Append(fmt.Errorf(\"Raw output format is only supported for single outputs\"))\n\t\treturn diags\n\t}\n\n\toutput, ok := outputs[name]\n\tif !ok {\n\t\tdiags = diags.Append(missingOutputError(name))\n\t\treturn diags\n\t}\n\n\tstrV, err := convert.Convert(output.Value, cty.String)\n\tif err != nil {\n\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Error,\n\t\t\t\"Unsupported value for raw output\",\n\t\t\tfmt.Sprintf(\n\t\t\t\t\"The -raw option only supports strings, numbers, and boolean values, but output value %q is %s.\\n\\nUse the -json option for machine-readable representations of output values that have complex types.\",\n\t\t\t\tname, output.Value.Type().FriendlyName(),\n\t\t\t),","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/views/output.go#L106-L142","documentation":"Returned by the raw output renderer when `terraform output -raw` is invoked without naming a specific output. The -raw mode renders a single value directly (no key, no quotes); with zero or multiple outputs there is no single value to emit, so it errors rather than guessing. This is a usage error, not a runtime/environment failure.","triggerScenarios":"Running `terraform output -raw` with no output NAME argument (expecting it to print all), or with multiple outputs in state and no name argument. Also when the command is invoked as `terraform output -raw NAME EXTRA`.","commonSituations":"Scripting `terraform output -raw` and forgetting the output name; copy-pasting from a -json example; expecting -raw to behave like default (list all) output.","solutions":["Pass the specific output name: `terraform output -raw <name>`.","List available outputs first with `terraform output` (no -raw) to find the exact name.","For multiple/all values in a script, use `terraform output -json` and parse with jq instead of -raw."],"exampleFix":"# before\nterraform output -raw\n# Raw output format is only supported for single outputs\n\n# after\nterraform output -raw instance_ip\n\n# or, for many values\nterraform output -json | jq -r '.instance_ip.value'","handlingStrategy":"validation","validationCode":"// before using -raw, ensure exactly one output name is requested\nfunc requireSingleOutputName(args []string) error {\n    if len(args) != 1 {\n        return fmt.Errorf(\"-raw requires exactly one output name\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a specific output name with -raw.","List outputs first with `terraform output` to confirm names.","Use `terraform output -json` for multi-value extraction in scripts.","Validate script inputs before invoking terraform output -raw."],"tags":["output","raw","usage","cli-arguments"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}