Parse environment variables in the bucket setting - #204
Open
jmariklecr wants to merge 1 commit into
Open
jmariklecr wants to merge 1 commit into
jmariklecr wants to merge 1 commit into
Conversation
jmariklecr
force-pushed
the
bugfix/parse-env-bucket
branch
from
September 2, 2026 18:59
ebc6c2f to
61ff4c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On
3.x, thebucketsetting isn't run throughEnv::parse()ingetDiskConfig(), so an env var reference reaches the S3 client verbatim. Withbucket: $S3_BUCKETin project config, every operation fails:(
%24S3_BUCKETbeing the URL-encoded literal$S3_BUCKET.)A regression from the 6.x port. On
2.x, env parsing was declarative viaEnvAttributeParserBehavior, covering seven attributes:keyId,secret,bucket,region,subfolder,cfDistributionId,cfPrefix. That behavior went away in the rewrite and each attribute became an explicitEnv::parse()call. Six of seven were converted,bucketwas missed.This should be a safe change. The same
Env::parseis used further down the same file:aws-s3/src/Filesystems/S3.php
Lines 368 to 375 in 861201f
Related issues
None. #181 is Craft 4 and unrelated.
2.xisn't affected (still uses the behavior).Note on verification / CI
The
3.xbranch's tooling doesn't appear to have been updated during the port, soneither phpstan nor ECS run cleanly.
composer installfails:composer.lockstill pinscraftcms/cms4.17.7 whilecomposer.jsonrequires^6.0.0(composer updateresolves cleanly to 6.0.0-alpha.16. I did not include the resulting composer.lock in this PR)composer phpstanfails:phpstan.neonincludescraftcms/phpstan's shared config, which scans../cms/src/Craft.php. That file doesn't exist in Craft 6. The legacyCraftclass now lives incraftcms/yii2-adapter, which this plugin doesn't require, so PHPStan can't run on this branch at all.composer check-csexits 1 with 7 pre-existing violations across the branch, none related to this change. I decided not to fix them considering they are unrelated to the current work..github/workflows/ci.ymlstill specifiescraft_version: '5'/php_version: '8.1'The change itself was verified manually on Craft 6.0.0-alpha.16 / PHP 8.5: with
bucketset via$S3_BUCKET, S3 operations return 400 before and succeed after.fileExists()true, correctsize(), and the CP Assets index browses the volume.Tooling issues probably belong in a separate PR.
Addendum
I used Claude Code to diagnose the issue and specifically checked whether it was isolated.
bucketingetDiskConfig()appears to be the only one missingEnv::parse().