Bug description
AmazonS3::__construct() computes the storage id with an unguarded
$this->params['key'] access:
// apps/files_external/lib/Lib/Storage/AmazonS3.php
// @todo: using `key` here may be problematic with different authentication methods and/or key rotation...
$this->id = 'amazon::external::' . md5($this->params['hostname'] . ':' . $this->params['bucket'] . ':' . $this->params['key']);
When an S3 external storage is mounted without a static access key — i.e. relying on
the AWS SDK default credential provider chain (environment, EC2 instance profile, ECS task
role, etc.) — the key param is absent. The credential layer already supports this:
S3ConnectionTrait::paramCredentialProvider() treats an empty/missing key as "no static
credentials" and rejects so the SDK falls through to its default provider chain:
// lib/private/Files/ObjectStore/S3ConnectionTrait.php
$key = empty($this->params['key']) ? null : $this->params['key'];
$secret = empty($this->params['secret']) ? null : $this->params['secret'];
...
if ($key && $secret) {
return Create::promiseFor(new Credentials($key, $secret, $sessionToken));
}
$msg = 'Could not find parameters set for credentials in config file.';
return new RejectedPromise(new CredentialsException($msg));
But the id computation in the constructor accesses key unconditionally, so PHP emits
Undefined array key "key" on every storage construction, which is logged as a warning.
The result is continuous log noise for a fully supported, working configuration.
The maintainer @todo sitting directly above the line already anticipates this fragility.
Steps to reproduce
- Add an Amazon S3 external storage.
- Configure it to authenticate via the ambient AWS credential chain rather than a static
access key (no key/secret provided).
- Browse the mount / let the storage be constructed.
- Check
nextcloud.log.
Expected behaviour
A credential-less S3 mount that authenticates via the default AWS provider chain should work
without emitting Undefined array key "key" warnings.
Actual behaviour
Every construction of the storage logs:
Undefined array key "key" at apps/files_external/lib/Lib/Storage/AmazonS3.php
Suggested fix
Guard the access when building the id (the value only contributes to a hash):
$this->params['key'] ?? ''
This aligns the id computation with paramCredentialProvider(), which already treats key
as optional. Happy to open a PR.
Related
Server configuration
- Nextcloud version: 34.0.3
- files_external app version: 1.26.0
- PHP version: 8.5.9
The offending line is present on master at the time of filing.
Bug description
AmazonS3::__construct()computes the storage id with an unguarded$this->params['key']access:When an S3 external storage is mounted without a static access key — i.e. relying on
the AWS SDK default credential provider chain (environment, EC2 instance profile, ECS task
role, etc.) — the
keyparam is absent. The credential layer already supports this:S3ConnectionTrait::paramCredentialProvider()treats an empty/missingkeyas "no staticcredentials" and rejects so the SDK falls through to its default provider chain:
But the id computation in the constructor accesses
keyunconditionally, so PHP emitsUndefined array key "key"on every storage construction, which is logged as a warning.The result is continuous log noise for a fully supported, working configuration.
The maintainer
@todositting directly above the line already anticipates this fragility.Steps to reproduce
access key (no key/secret provided).
nextcloud.log.Expected behaviour
A credential-less S3 mount that authenticates via the default AWS provider chain should work
without emitting
Undefined array key "key"warnings.Actual behaviour
Every construction of the storage logs:
Suggested fix
Guard the access when building the id (the value only contributes to a hash):
This aligns the id computation with
paramCredentialProvider(), which already treatskeyas optional. Happy to open a PR.
Related
Server configuration
The offending line is present on
masterat the time of filing.