Skip to content

fix: correct Go time-format tokens for S3 object key date path#312

Closed
ThiagoBauken wants to merge 2 commits into
asternic:mainfrom
ThiagoBauken:fix/s3-key-date-format
Closed

fix: correct Go time-format tokens for S3 object key date path#312
ThiagoBauken wants to merge 2 commits into
asternic:mainfrom
ThiagoBauken:fix/s3-key-date-format

Conversation

@ThiagoBauken

Copy link
Copy Markdown
Contributor

Problem

GenerateS3Key builds the date segments of every S3 object key with invalid Go time-format tokens:

year := now.Format("2025")
month := now.Format("05")
day := now.Format("25")

Go's reference time is 2006-01-02 15:04:05, so the only valid tokens are 2006 / 01 / 02. 05 is the seconds field, and 2025 / 25 aren't recognized layouts — so media is stored under nonsensical, non-chronological folders (the "month" segment actually renders seconds). This breaks date-based browsing and any S3 lifecycle/retention rule keyed on the object path.

Fix

Use the correct tokens 2006 / 01 / 02.

Testing

  • go build ./...
  • go vet ./...
  • Single file, 3-line change plus an explanatory comment.

GenerateS3Key built the year/month/day segments of every S3 object key with
now.Format("2025"), now.Format("05") and now.Format("25"). None are valid Go
layout tokens (the reference time is "2006-01-02 15:04:05") and "05" is the
seconds field, so uploaded media was filed under nonsensical, non-chronological
paths — breaking date-based browsing and S3 lifecycle/retention rules.

Use the correct tokens "2006"/"01"/"02".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request corrects the Go time formatting layout tokens in s3manager.go from incorrect values ("2025", "05", "25") to the correct reference layout tokens ("2006", "01", "02") to ensure proper chronological folder organization. There are no review comments, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Add TestGenerateS3KeyDateFormat: the year/month/day path segments must equal
time.Now().Format("2006"/"01"/"02") and have widths 4/2/2. Verified red/green —
fails against the previous "2025"/"05"/"25" tokens (which yielded a 5-digit
"year" and a seconds-based "month") and passes with the corrected tokens.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ThiagoBauken

Copy link
Copy Markdown
Contributor Author

Closing to consolidate my recent PRs into a smaller, focused set that's easier to review — I'll resubmit the changes grouped together. Sorry for the churn, and thanks!

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.

1 participant