localstack / localstack/aws-cdk-local

AWS_S3_FORCE_PATH_STYLE environment variable is not correctly recognized

Open Beginner friendly
#127 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.