{"record":{"id":"550abeecf3ee7d2c","repo":"hashicorp/terraform","slug":"invalid-empty-string-in-scripts","errorCode":null,"errorMessage":"invalid empty string in 'scripts'","messagePattern":"invalid empty string in 'scripts'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/builtin/provisioners/remote-exec/resource_provisioner.go","lineNumber":163,"sourceCode":"\tp.cancel()\n\treturn nil\n}\n\nfunc (p *provisioner) Close() error {\n\treturn nil\n}\n\n// generateScripts takes the configuration and creates a script from each inline config\nfunc generateScripts(inline cty.Value) ([]string, error) {\n\tvar lines []string\n\tfor _, l := range inline.AsValueSlice() {\n\t\tif l.IsNull() {\n\t\t\treturn nil, errors.New(\"invalid null string in 'scripts'\")\n\t\t}\n\n\t\ts := l.AsString()\n\t\tif s == \"\" {\n\t\t\treturn nil, errors.New(\"invalid empty string in 'scripts'\")\n\t\t}\n\t\tlines = append(lines, s)\n\t}\n\tlines = append(lines, \"\")\n\n\treturn []string{strings.Join(lines, \"\\n\")}, nil\n}\n\n// collectScripts is used to collect all the scripts we need\n// to execute in preparation for copying them.\nfunc collectScripts(v cty.Value) ([]io.ReadCloser, error) {\n\t// Check if inline\n\tif inline := v.GetAttr(\"inline\"); !inline.IsNull() {\n\t\tscripts, err := generateScripts(inline)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/builtin/provisioners/remote-exec/resource_provisioner.go#L145-L181","documentation":"Error from generateScripts() when an 'inline' list element is an empty string (\"\"). Each inline script must be non-empty.","triggerScenarios":"provisioner \"remote-exec\" { inline = [\"echo hi\", \"\"] } — an empty element, often from a list variable with blank entries.","commonSituations":"A variable populated from an external source that yields blank strings; leftover placeholder in a list literal.","solutions":["Remove empty entries: inline = [for c in var.commands : c if c != \"\"].","Sanitize the source list so all entries are real command strings."],"exampleFix":"// before\nprovisioner \"remote-exec\" {\n  inline = var.commands\n}\n// after\nprovisioner \"remote-exec\" {\n  inline = [for c in var.commands : c if c != \"\"]\n}","handlingStrategy":"validation","validationCode":"# Drop empty strings from inline:\n# inline = [for c in var.commands : c if c != \"\"]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Sanitize external command lists for blank entries.","Add a terraform validate step in CI.","Prefer templated heredocs over hand-built string lists."],"tags":["terraform","provisioner","remote-exec","config-validation","hcl"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}