Skip to content

feat: update S3 bucket name in configuration and add logging for buck…#36

Merged
weited merged 4 commits intomainfrom
feature/check-AWS-config
Jun 16, 2025
Merged

feat: update S3 bucket name in configuration and add logging for buck…#36
weited merged 4 commits intomainfrom
feature/check-AWS-config

Conversation

@weited
Copy link
Copy Markdown
Collaborator

@weited weited commented Jun 16, 2025

…et listing

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the default S3 bucket fallback in the application configuration and adds logging of existing S3 buckets on application startup.

  • Added a default fallback value for AWS_S3_BUCKET_NAME in application.yaml
  • Introduced a @PostConstruct method in AwsConfig to list and log S3 buckets at startup

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/main/resources/application.yaml Default S3 bucket name fallback set to oceancurrent-testing
src/main/java/au/org/aodn/oceancurrent/configuration/aws/AwsConfig.java Added runTestToListS3Buckets startup method for bucket listing
Comments suppressed due to low confidence (2)

src/main/java/au/org/aodn/oceancurrent/configuration/aws/AwsConfig.java:67

  • [nitpick] The method name runTestToListS3Buckets is misleading since this code executes in production; consider renaming it to listS3BucketsOnStartup or clarifying its purpose.
private void runTestToListS3Buckets() {

src/main/resources/application.yaml:44

  • [nitpick] The new default bucket name oceancurrent-testing should be documented in the project’s configuration guide or README so all developers understand the fallback behavior.
bucket-name: ${AWS_S3_BUCKET_NAME:oceancurrent-testing}

Comment on lines +66 to +67
@PostConstruct
private void runTestToListS3Buckets() {
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using @PostConstruct to run an S3 bucket listing at startup can introduce unnecessary network calls and slow application initialization in production; consider moving this into a dedicated health endpoint or enabling it only under a non-production profile.

Suggested change
@PostConstruct
private void runTestToListS3Buckets() {
public void listS3BucketsForHealthCheck() {

Copilot uses AI. Check for mistakes.

@PostConstruct
private void runTestToListS3Buckets() {
try (S3Client s3Client = s3Client()) {
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instantiating a new S3Client instead of injecting the existing bean bypasses Spring’s lifecycle and configuration; inject the S3Client bean to leverage singleton scope and improve testability.

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +74
} catch (Exception e) {
log.error("Unexpected error during S3 bucket listing:", e);
Copy link

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching a generic Exception can mask unexpected errors; narrow this catch block to specific exception types or rethrow unhandled exceptions to ensure issues aren’t silently ignored.

Suggested change
} catch (Exception e) {
log.error("Unexpected error during S3 bucket listing:", e);
} catch (RuntimeException e) {
log.error("Unexpected runtime error during S3 bucket listing:", e);
throw e; // Rethrow to avoid masking critical runtime exceptions
} catch (Exception e) {
log.error("Unexpected checked exception during S3 bucket listing:", e);
throw new RuntimeException("Unhandled exception during S3 bucket listing", e); // Wrap and rethrow

Copilot uses AI. Check for mistakes.
@weited weited merged commit 2bc93a8 into main Jun 16, 2025
1 check failed
@weited weited deleted the feature/check-AWS-config branch June 16, 2025 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants