{"record":{"id":"7e705956aad11c9d","repo":"hashicorp/terraform","slug":"architecture-portion-must-not-contain-whitespace","errorCode":null,"errorMessage":"architecture portion must not contain whitespace","messagePattern":"architecture portion must not contain whitespace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/getproviders/types.go","lineNumber":126,"sourceCode":"\tdefault:\n\t\treturn p.Arch < other.Arch\n\t}\n}\n\n// ParsePlatform parses a string representation of a platform, like\n// \"linux_amd64\", or returns an error if the string is not valid.\nfunc ParsePlatform(str string) (Platform, error) {\n\tparts := strings.Split(str, \"_\")\n\tif len(parts) != 2 {\n\t\treturn Platform{}, fmt.Errorf(\"must be two words separated by an underscore\")\n\t}\n\n\tos, arch := parts[0], parts[1]\n\tif strings.ContainsAny(os, \" \\t\\n\\r\") {\n\t\treturn Platform{}, fmt.Errorf(\"OS portion must not contain whitespace\")\n\t}\n\tif strings.ContainsAny(arch, \" \\t\\n\\r\") {\n\t\treturn Platform{}, fmt.Errorf(\"architecture portion must not contain whitespace\")\n\t}\n\n\treturn Platform{\n\t\tOS:   os,\n\t\tArch: arch,\n\t}, nil\n}\n\n// CurrentPlatform is the platform where the current program is running.\n//\n// If attempting to install providers for use on the same system where the\n// installation process is running, this is the right platform to use.\nvar CurrentPlatform = Platform{\n\tOS:   runtime.GOOS,\n\tArch: runtime.GOARCH,\n}\n\n// PackageMeta represents the metadata related to a particular downloadable","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/getproviders/types.go#L108-L144","documentation":"Returned by ParsePlatform when the architecture portion (substring after the underscore) contains any of space, tab, newline, or carriage return. Mirrors the OS whitespace check; runs only after the two-part split succeeds.","triggerScenarios":"A platform string like 'linux_amd64 ' (trailing space), 'linux_amd64\\t', or 'linux_am d64'. The whitespace lives in the arch token rather than the OS token.","commonSituations":"Trailing newline or space from reading a file line into ParsePlatform; shell word-splitting on the second token; config formatter inserting whitespace.","solutions":["Trim surrounding whitespace from the platform string before parsing.","When reading platform from a file, strip the trailing newline (e.g. via strings.TrimSpace).","Quote shell variables to avoid word-splitting.","Validate user input rejects whitespace before passing to ParsePlatform."],"exampleFix":"// before\nline, _ := bufio.NewReader(f).ReadString('\\n')\np, err := ParsePlatform(line) // line has trailing \\n\n// after\nline, _ := bufio.NewReader(f).ReadString('\\n')\np, err := ParsePlatform(strings.TrimSpace(line))","handlingStrategy":"validation","validationCode":"// Reject arch tokens with whitespace before parsing.\nfunc validateArchToken(s string) error {\n    parts := strings.Split(s, \"_\")\n    if len(parts) != 2 { return errors.New(\"bad shape\") }\n    if strings.ContainsAny(parts[1], \" \\t\\n\\r\") { return errors.New(\"arch has whitespace\") }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip trailing newlines when reading platform from files.","Quote shell variables to prevent word splitting.","Trim user-supplied platform values before validation."],"tags":["platform","validation","whitespace","parsing","getproviders"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}