{"record":{"id":"b629b30ffcf1f585","repo":"alibaba/open-code-review","slug":"invalid-s-for-s-q-contains-whitespace","errorCode":null,"errorMessage":"invalid %s for %s: %q contains whitespace","messagePattern":"invalid (.+?) for (.+?): %q contains whitespace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/opencodereview/config_cmd.go","lineNumber":719,"sourceCode":"func providerAcceptsAWSSettings(providerName string, entry *ProviderEntry) bool {\n\tif entry.Protocol != \"\" {\n\t\treturn llm.NormalizeProtocol(entry.Protocol) == llm.ProtocolAnthropicBedrock\n\t}\n\tpreset, isPreset := llm.LookupProvider(providerName)\n\treturn isPreset && preset.AmbientAuth\n}\n\n// normalizeAWSSetting trims the value and rejects the shapes AWS itself will\n// not accept. Region names are deliberately not checked against a fixed list:\n// AWS adds regions faster than any embedded list stays correct, and a wrong one\n// already surfaces at request time.\nfunc normalizeAWSSetting(field, key, value string) (string, error) {\n\ttrimmed := strings.TrimSpace(value)\n\tif trimmed == \"\" {\n\t\treturn \"\", nil // clearing the field hands the decision back to the AWS chain\n\t}\n\tif strings.ContainsAny(trimmed, \" \\t\\n\") {\n\t\treturn \"\", fmt.Errorf(\"invalid %s for %s: %q contains whitespace\", field, key, value)\n\t}\n\treturn trimmed, nil\n}\n\nfunc parseModelListValue(value string) ([]string, error) {\n\tvalue = strings.TrimSpace(value)\n\tif value == \"\" {\n\t\treturn nil, nil\n\t}\n\n\tif strings.HasPrefix(value, \"[\") {\n\t\tvar models []string\n\t\tif err := json.Unmarshal([]byte(value), &models); err == nil {\n\t\t\treturn normalizeModelList(models), nil\n\t\t}\n\t\tvalue = strings.TrimSpace(strings.TrimSuffix(strings.TrimPrefix(value, \"[\"), \"]\"))\n\t}\n","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/cmd/opencodereview/config_cmd.go#L701-L737","documentation":"normalizeAWSSetting validates values for aws_region/aws_profile. After trimming, an empty value is allowed (clears the field), but any remaining whitespace (spaces, tabs, newlines) inside the value is rejected, since AWS region names and profile names can never contain whitespace. The error names the field, provider key, and the offending raw value.","triggerScenarios":"`ocr config set providers.<name>.aws_region \"us east 1\"` or a value with a trailing unquoted space plus interior whitespace, e.g. \"us-east-1 \" won't trigger (trimmed), but \"us east-1\" or a newline-pasted value will.","commonSituations":"Pasting a multi-line value from a terminal; typing 'us east 1' instead of 'us-east-1'; shell word-splitting injecting spaces into the value.","solutions":["Correct the value to a whitespace-free identifier, e.g. us-east-1","Quote the argument in the shell to avoid word-splitting","Pass an empty value ('') to clear the field and defer to the AWS credential chain"],"exampleFix":"// before\nocr config set providers.foo.aws_region \"us east 1\"\n// after\nocr config set providers.foo.aws_region \"us-east-1\"","handlingStrategy":"validation","validationCode":"v=\"us-east-1\"\n[[ \"$v\" =~ [[:space:]] ]] && echo \"contains whitespace\" || ocr config set providers.foo.aws_region \"$v\"","typeGuard":null,"tryCatchPattern":"trimmed := strings.TrimSpace(value)\nif strings.ContainsAny(trimmed, \" \\t\\n\") {\n    return fmt.Errorf(\"invalid %s for %s: %q contains whitespace\", field, key, value)\n}","preventionTips":["AWS regions/profiles are whitespace-free identifiers","Quote values to prevent shell word-splitting","Pass an empty value to clear the field rather than a space"],"tags":["cli","config","aws","validation"],"backgroundTag":"whitespace-in-config-value","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}