{"record":{"id":"57ad0588c27a7f0e","repo":"hashicorp/terraform","slug":"invalid-empty-string-in-script","errorCode":null,"errorMessage":"invalid empty string in 'script'","messagePattern":"invalid empty string in 'script'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/builtin/provisioners/remote-exec/resource_provisioner.go","lineNumber":195,"sourceCode":"\t\tscripts, err := generateScripts(inline)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvar r []io.ReadCloser\n\t\tfor _, script := range scripts {\n\t\t\tr = append(r, io.NopCloser(bytes.NewReader([]byte(script))))\n\t\t}\n\n\t\treturn r, nil\n\t}\n\n\t// Collect scripts\n\tvar scripts []string\n\tif script := v.GetAttr(\"script\"); !script.IsNull() {\n\t\ts := script.AsString()\n\t\tif s == \"\" {\n\t\t\treturn nil, errors.New(\"invalid empty string in 'script'\")\n\t\t}\n\t\tscripts = append(scripts, s)\n\t}\n\n\tif scriptList := v.GetAttr(\"scripts\"); !scriptList.IsNull() {\n\t\tfor _, script := range scriptList.AsValueSlice() {\n\t\t\tif script.IsNull() {\n\t\t\t\treturn nil, errors.New(\"invalid null string in 'script'\")\n\t\t\t}\n\t\t\ts := script.AsString()\n\t\t\tif s == \"\" {\n\t\t\t\treturn nil, errors.New(\"invalid empty string in 'script'\")\n\t\t\t}\n\t\t\tscripts = append(scripts, s)\n\t\t}\n\t}\n\n\t// Open all the scripts","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/builtin/provisioners/remote-exec/resource_provisioner.go#L177-L213","documentation":"Error from collectScripts() when the singular 'script' attribute of the remote-exec provisioner is non-null but equals the empty string \"\". The script path must be non-empty.","triggerScenarios":"provisioner \"remote-exec\" { script = \"\" } — typically from a variable resolving to an empty string.","commonSituations":"A var.script_path that defaults to \"\" and is never overridden; templating that blanks out the path.","solutions":["Set 'script' to a real path, or omit it and use 'inline'/'scripts' instead.","Guard with a conditional: only include the provisioner when the path is set."],"exampleFix":"// before\nprovisioner \"remote-exec\" {\n  script = var.script_path\n}\n// after\nprovisioner \"remote-exec\" {\n  script = \"/opt/scripts/bootstrap.sh\"\n}","handlingStrategy":"validation","validationCode":"# Only set 'script' when the path is non-empty, or switch to inline:\n# script = var.script_path != \"\" ? var.script_path : null\n# Better: guard the whole provisioner with count.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give script-path variables a real default or omit them.","Use count = 0 on the resource when the script path is unset.","Validate configuration in CI."],"tags":["terraform","provisioner","remote-exec","config-validation","hcl"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}