aws / aws/aws-tools-for-powershell
All cmdlets fail with "Request headers must contain only ASCII characters." for some locales
- Dominant language
- C#
- Stars
- 298
- Forks
- 102
- Avg merge
- 7d 17m
- Merged PRs (30d)
- 2
Description
## Description
If I run any AWS cmdlet from AWS.Tools that communicate with AWS services fail after about 35 seconds with the error message "Request headers must contain only ASCII characters.".
$PSCulture is set to sv-SE in PowerShell.
If I go into macOS system settings and change regional locale settings to country USA instead of Sweden, then run the same thing, it works just fine.
Also, if I start a pwsh terminal session in VS Code, it defaults to en-US for $PSCulture, even if the system locale is set to Sweden (sv-SE). In VS Code terminal it also works fine there.
Presumably since Swedish includes a few non-ASCII characters in the alphabet, this may be part of what is causing the problem here. I noticed that there was a query from 2019 in the AWS community forums for PowerShell scripting where a person had the same issue on macOS (10.15), with no response. So it does not seem to be a new issue.
## Reproduction Steps
1. In macOS regional settings, change the country to Sweden and change the primary language to Sweden. Accept all changes as-is.
2. Start an Apple Terminal with pwsh
3. Verify that $PSCulture is set to 'sv-SE'
4. Run any AWS cmdlet that uses AWS services
### Logs
With $PSCulture = 'sv-SE':
PS /Users/erikl> Get-EC2Vpc -ProfileName erik -region eu-west-1 -verbose -Debug
DEBUG: Credentials obtained from stored profile named 'erik'
DEBUG: Region obtained from region parameter with value 'eu-west-1'
VERBOSE: Invoking Amazon Elastic Compute Cloud (EC2) operation 'DescribeVpcs' in region 'eu-west-1'
Get-EC2Vpc: Request headers must contain only ASCII characters.
with $PSCulture = 'en-US' or $PSCulture = '':
PS /Users/erikl> Get-EC2Vpc -ProfileName erik -region eu-west-1 -verbose -Debug
DEBUG: Credentials obtained from stored profile named 'erik'
DEBUG: Region obtained from region parameter with value 'eu-west-1'
VERBOSE: Invoking Amazon Elastic Compute Cloud (EC2) operation 'DescribeVpcs' in region 'eu-west-1'
CidrBlock : 172.31.0.0/16
CidrBlockAssociationSet : {vpc-cidr-assoc-1dfa7777}
DhcpOptionsId : dopt-3baf7999
InstanceTenancy : default
Ipv6CidrBlockAssociationSet : {}
IsDefault : True
OwnerId : 123456789012
State : available
Tags : {}
VpcId : vpc-6f741111
### Environment
AWS Tools for PowerShell 4.1.7.0.
macOS 11.1 (BigSur)
PowerShell 7.1.1
Tested in Apple Terminal and VS Code terminal, see above.
## Resolution
---
This is a :bug: bug-report
Contributor guide
Research direction
Reproduce the failure from an Apple Terminal with pwsh using $PSCulture='sv-SE' and Get-EC2Vpc, then compare it with en-US. Trace the AWS cmdlet request and header construction from that entry point; done means AWS service cmdlets complete successfully under sv-SE without the ASCII-header error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, macos, powershell
- Domain
- api, cli, internationalization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100