localstack / localstack/aws-cdk-local
AWS_S3_FORCE_PATH_STYLE environment variable is not correctly recognized
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 305
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Note: This issue was translated and drafted with the assistance of AI.
## Description
Even when the environment variable `AWS_S3_FORCE_PATH_STYLE` is set to `1` or `true`, PathStyle remains disabled.
## Version
3.0.4
## Root Cause
In `bin/cdklocal`, the `shouldForcePathStyle` function passes the *value* of the environment variable to `isEnvTrue` instead of the *variable name*.
Since `isEnvTrue` in `src/index.js` performs a lookup using the provided argument as a key for `process.env`, it fails to find the correct value.
bin/cdklocal
```js
const shouldForcePathStyle = () => {
// It currently passes the value (e.g., "1" or "true") instead of the key name
if (isEnvTrue(process.env.AWS_S3_FORCE_PATH_STYLE)) {
return true;
}
const endpointUrl = process.env.AWS_ENDPOINT_URL || "";
try {
return new URL(endpointUrl).hostname.includes(".sandbox.");
} catch {
return false;
}
};
```
src/index.js
```js
const isEnvTrue = (envName) => ["1", "true"].includes(process.env[envName]);
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading shouldForcePathStyle in bin/cdklocal and the isEnvTrue helper in src/index.js. Verify how AWS_S3_FORCE_PATH_STYLE values of 1 and true are looked up, then confirm that enabling the variable makes PathStyle active without changing the existing endpoint hostname behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript
- Domain
- cli, cloud
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100