{"record":{"id":"7d910d9ef84af5e7","repo":"hashicorp/terraform","slug":"tag-elements-must-be-strings","errorCode":null,"errorMessage":"tag elements must be strings","messagePattern":"tag elements must be strings","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend.go","lineNumber":523,"sourceCode":"\t\t\tif val.Type().IsObjectType() || val.Type().IsMapType() {\n\t\t\t\tfor k, v := range val.AsValueMap() {\n\t\t\t\t\tif v.Type() != cty.String {\n\t\t\t\t\t\tdiags = diags.Append(errors.New(\"tag object values must be strings\"))\n\t\t\t\t\t\treturn ret, diags\n\t\t\t\t\t}\n\t\t\t\t\ttagsAsMap[k] = v.AsString()\n\t\t\t\t}\n\t\t\t\tlog.Printf(\"[TRACE] cloud: using tags %q from cloud config block\", tagsAsMap)\n\t\t\t\tret.workspaceMapping.TagsAsMap = tagsAsMap\n\t\t\t} else if val.Type().IsTupleType() || val.Type().IsSetType() {\n\t\t\t\tvar tagsAsSet []string\n\t\t\t\tlength := val.LengthInt()\n\t\t\t\tif length > 0 {\n\t\t\t\t\tit := val.ElementIterator()\n\t\t\t\t\tfor it.Next() {\n\t\t\t\t\t\t_, v := it.Element()\n\t\t\t\t\t\tif !v.Type().Equals(cty.String) {\n\t\t\t\t\t\t\tdiags = diags.Append(errors.New(\"tag elements must be strings\"))\n\t\t\t\t\t\t\treturn ret, diags\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif vs := v.AsString(); vs != \"\" {\n\t\t\t\t\t\t\ttagsAsSet = append(tagsAsSet, vs)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlog.Printf(\"[TRACE] cloud: using tags %q from cloud config block\", tagsAsSet)\n\t\t\t\tret.workspaceMapping.TagsAsSet = tagsAsSet\n\t\t\t} else {\n\t\t\t\tdiags = diags.Append(fmt.Errorf(\"tags must be a set or object, not %s\", val.Type().FriendlyName()))\n\t\t\t\treturn ret, diags\n\t\t\t}\n\t\t}\n\t\tif val := workspaces.GetAttr(\"project\"); !val.IsNull() {\n\t\t\tproject = val.AsString()\n\t\t\tlog.Printf(\"[TRACE] cloud: found project name %q in cloud config block\", project)","sourceCodeStart":505,"sourceCodeEnd":541,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend.go#L505-L541","documentation":"Config-parsing diagnostic from the cloud backend when workspaces.tags is a tuple/set type but an element's cty type is not cty.String. All set/tuple tag elements must be strings so they can be collected into []string.","triggerScenarios":"workspaces { tags = [\"a\", 1] } — a non-string element in a set-type tags value; or a list(any) variable containing a non-string.","commonSituations":"Mixing types in a tags list; a variable typed as list(any).","solutions":["Make every element a string, e.g. tags = [\"a\", \"1\"].","Type the variable as set(string) or list(string)."],"exampleFix":"// before\nworkspaces {\n  tags = [\"Environment:prod\", 42]\n}\n// after\nworkspaces {\n  tags = [\"Environment:prod\", \"42\"]\n}","handlingStrategy":"validation","validationCode":"# Type the tags variable as set(string)/list(string):\nvariable \"tags\" { type = set(string) }\n# Then: workspaces { tags = var.tags }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Type tag-set variables as set(string).","Avoid list(any) for tag collections.","Validate configuration in CI."],"tags":["terraform","cloud-backend","config-validation","hcl","tags"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}