{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/builtin/provisioners/remote-exec/resource_provisioner.go#L145-L181","documentation":"Thrown by remote-exec generateScripts (resource_provisioner.go:163) when an `inline` element is a non-null but empty string (\"\"). Each inline command must have content; an empty element would inject a blank line into the generated script, so the provisioner rejects it.","triggerScenarios":"A provisioner \"remote-exec\" block whose `inline` list contains \"\", e.g. `inline = [\"echo hi\", \"\", \"echo bye\"]`, hitting the `s == \"\"` branch.","commonSituations":"Trailing/leading empty strings from list concatenation. Variables that default to \"\" and are appended unconditionally.","solutions":["Remove empty strings from the inline list, e.g. `inline = [for s in var.cmds : s if s != \"\"]`.","Ensure each inline element is a real command string."],"exampleFix":"# before\nprovisioner \"remote-exec\" {\n  inline = [\"echo hi\", \"\", \"echo bye\"]\n}\n# after\nprovisioner \"remote-exec\" {\n  inline = [\"echo hi\", \"echo bye\"]\n}","handlingStrategy":"validation","validationCode":"func inlineHasNoEmpty(xs []string) error {\n    for _, s := range xs {\n        if s == \"\" { return errors.New(\"invalid empty string in 'scripts'\") }\n    }\n    return nil\n}","typeGuard":"func inlineAllNonEmpty(v cty.Value) bool {\n    for _, e := range v.AsValueSlice() {\n        if !e.IsNull() && e.AsString() == \"\" { return false }\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["Strip empty strings: [for s in xs : s if s != \"\"].","Avoid concatenating lists that can yield empty entries."],"tags":["terraform","provisioner","remote-exec","validation","config"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}