fix(storage): enable storage features when using default GCS endpoint#3135
Merged
Conversation
The admin UI flag `storageEnabled` previously required a non-blank `storage.endpoint`, which hid storage features when GCS was used with the default `storage.googleapis.com` host. Treat GCS as enabled when a bucket is configured even without an explicit endpoint, and skip the custom-host override in `GcsStorageClient` for the default endpoint so real Google credentials are used instead of `NoCredentials`.
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.
Summary
The admin UI's
storageEnabledflag previously required a non-blankstorage.endpoint, which hid storage-dependent features (e.g. thumbnail/asset storage admin links) whenever GCS was used with the defaultstorage.googleapis.comhost. This change recognizes GCS-with-default-endpoint as a valid enabled configuration and stopsGcsStorageClientfrom treating the default host as a custom endpoint.Changes Made
SystemHelper: extracted a newisStorageEnabled(FessConfig)helper. Storage is now enabled whenstorage.bucketis set AND eitherstorage.endpointis non-blank orstorage.typeisgcs(case-insensitive).setupStorageInfodelegates to this helper.GcsStorageClient:isDefaultEndpoint(String)to detect the default GCS host (storage.googleapis.com, HTTPS, default port). Custom-host/NoCredentialsoverrides are now skipped when the configured endpoint matches the default, so real Google credentials are used.close()short-circuits whenstorageis null.SystemHelperTest#test_isStorageEnabledcovers S3-with-endpoint, GCS-without-endpoint (both cases), unrelated type, missing bucket, and null config.GcsStorageClientTest#test_isDefaultEndpointcovers bare host, scheme/path variants, explicit default port, plus negative cases (HTTP, non-default port, hostname embedded in path).Testing
mvn test -Dtest=SystemHelperTestmvn test -Dtest=GcsStorageClientTestBreaking Changes
None. The previous behavior is preserved whenever an explicit endpoint is configured; only the GCS-default-endpoint case becomes "enabled" instead of "disabled".
Additional Notes
NoCredentialsand the host override.isStorageEnabledis intentionally null-safe so callers don't have to guard against an uninitializedFessConfig.