{"record":{"id":"d74e925e5a374043","repo":"hashicorp/terraform","slug":"invalid-null-string-in-script","errorCode":null,"errorMessage":"invalid null string in 'script'","messagePattern":"invalid null string in 'script'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/builtin/provisioners/remote-exec/resource_provisioner.go","lineNumber":203,"sourceCode":"\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\n\tvar fhs []io.ReadCloser\n\tfor _, s := range scripts {\n\t\tfh, err := os.Open(s)\n\t\tif err != nil {\n\t\t\tfor _, fh := range fhs {\n\t\t\t\tfh.Close()\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"Failed to open script '%s': %v\", s, err)","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/builtin/provisioners/remote-exec/resource_provisioner.go#L185-L221","documentation":"Error from collectScripts() while iterating the 'scripts' list of the remote-exec provisioner: a list element is null (cty.NullVal). Each scripts entry (a file path) must be a non-null string.","triggerScenarios":"provisioner \"remote-exec\" { scripts = [\"a.sh\", null] } — a null path element, commonly from a list variable with a null item.","commonSituations":"var.script_paths containing a null element; conditional list building that leaves a null.","solutions":["Filter nulls: scripts = [for s in var.script_paths : s if s != null].","Ensure every list element is a real file path string."],"exampleFix":"// before\nprovisioner \"remote-exec\" {\n  scripts = var.script_paths\n}\n// after\nprovisioner \"remote-exec\" {\n  scripts = [for s in var.script_paths : s if s != null]\n}","handlingStrategy":"validation","validationCode":"# Filter nulls from the scripts list:\n# scripts = [for s in var.script_paths : s if s != null]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Type the variable as list(string).","Filter nulls when building the list dynamically.","Run terraform validate 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"}