aws / aws/aws-tools-for-powershell

credential_process with space in file path fails even with double quotation marks

Open
#393 3 comments 0 reactions 0 assignees View on GitHub
bug p2 queued
Dominant language
C#
Stars
298
Forks
102
Avg merge
7d 17m
Merged PRs (30d)
2

Description

### Describe the bug

As described in this page

- https://docs.aws.amazon.com/sdkref/latest/guide/feature-process-credentials.html

I am attempting to use the `credential_process` in a `~/.aws/config` file. I have it pointing to a custom Powershell script that handles some cert issues first, then calls the aws_signing_helper.exe utility and outputs the result. As such, my config file looks like:
```
[default]
region = eu-west-1
credential_process = "C:\Program Files\PowerShell\7\pwsh.exe" -ExecutionPolicy Bypass -File "C:\path_without_spaces\GetCredentials.ps1"
```

This works for the current AWS CLI as well as Python's boto3 package but does not work for AWS Tools for Powershell, which outputs, e.g. with Get-S3Object:
```
Get-S3Object: Command returned non-zero exit value 1 with the error - 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
```
If I change the contents of the config file to:
```
[default]
region = eu-west-1
credential_process = C:\PROGRA~1\PowerShell\7\pwsh.exe -ExecutionPolicy Bypass -File "C:\path_without_spaces\GetCredentials.ps1"
```
then the command succeeds. I tested this with both 5.0.28 and 4.1.874 and the behavior is identical. I did not test any other version.

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Expected Behavior

It is expected that the AWS Tools for Powershell can handle spaces in the files paths as indicated by the documentation referenced.

### Current Behavior

Error:
```
Command returned non-zero exit value 1 with the error - 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
```

### Reproduction Steps

Use a ~/.aws/config file with 'credential_process' with a space in the command path.

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS Tools for PowerShell version used

AWS.Tools.S3 4.1.874
AWS.Tools.S3 5.0.28

### PowerShell version used

Name Value
---- -----
PSVersion 7.5.2
PSEdition Core
GitCommitId 7.5.2
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

### Operating System and version

Windows 11 Enterprise, Version 10.0.26100 Build 26100

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the credential_process entry in ~/.aws/config and Get-S3Object on Windows. Trace how AWS Tools for PowerShell parses and invokes the quoted command, comparing it with the working PROGRA~1 form; done means paths containing spaces work as documented without changing the configuration workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
authentication, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.