Skip to content

Conversation

@anhtaw
Copy link

@anhtaw anhtaw commented Oct 16, 2025

Description

Fixing a bug in the awss3receiver key generation logic where object keys could contain
an unexpected leading slash (/year=...) when s3_prefix was empty and s3_partition_format
was not explicitly set.
This change makes the behavior consistent between default and custom s3_partition_format
by ensuring keys do not start with a slash unless explicitly configured.

Additional logic was added to handle cases where prefix equals / or //, preserving the
user-defined format without stripping or duplicating slashes.


Link to tracking issue

Fixes #43522


Testing

  • Added new unit tests in s3reader_test.go covering:
    • Default s3_partition_format behavior with empty prefix.
    • Explicit s3_partition_format override.
    • Custom prefix values / and //.
  • Verified generated S3 keys match expected format:
    • year=2025/month=10/day=15/... (no leading slash)
    • /year=2025/... when prefix = /.
  • All existing tests pass (make test).

Documentation

No external documentation changes required.
Internal behavior change documented in code comments for getObjectPrefixForTime().

@anhtaw anhtaw requested review from a team and atoulme as code owners October 16, 2025 03:41
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: anhtaw / name: broname (bdbca67)

@github-actions github-actions bot added the first-time contributor PRs made by new contributors label Oct 16, 2025
@github-actions
Copy link
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better!

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

@anhtaw
Copy link
Author

anhtaw commented Oct 17, 2025

Thanks for the contribution @anhtaw! please ensure a changelog entry is added https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#adding-a-changelog-entry

Hi @codeboten Changelog entry has been added. Thanks for the reminder!

@anhtaw anhtaw requested a review from codeboten October 17, 2025 15:32
@anhtaw anhtaw requested a review from atoulme October 21, 2025 07:01
Copy link
Contributor

@adcharre adcharre left a comment

Choose a reason for hiding this comment

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

Looks OK to me and seems to follow similar behaviour as to the S3 Exporter.

@atoulme atoulme added the ready to merge Code review completed; ready to merge by maintainers label Oct 24, 2025
@github-actions
Copy link
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time contributor PRs made by new contributors ready to merge Code review completed; ready to merge by maintainers receiver/awss3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unable to read S3 objects when keys start with leading slash ("/") — path.Join removes leading "/" from s3_prefix

5 participants