Skip to content

fix: fix concurrency in Tagged - #2183

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
TanvirTian:fix/tagged-concurrency
Sep 22, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
TanvirTian:fix/tagged-concurrency

Conversation

@TanvirTian

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
Tagged.Tags() sorts the shared tag.tags slice while holding a read lock, which can cause a data race when called concurrently.

This changes Tags() to use an exclusive lock while sorting and return a cloned slice so callers cannot modify the internal slice.

Added tests covering concurrent access and returned-slice isolation.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2181

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.75%. Comparing base (8016ba3) to head (e667226).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2183      +/-   ##
==========================================
- Coverage   87.79%   87.75%   -0.04%     
==========================================
  Files         139      139              
  Lines        5694     5694              
==========================================
- Hits         4999     4997       -2     
- Misses        415      417       +2     
  Partials      280      280              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@TanvirTian

Copy link
Copy Markdown
Contributor Author

/lgtm

thanks :) . could you merge it when you get a chance?

@TerryHowe
TerryHowe merged commit be79214 into oras-project:main Sep 22, 2026
9 checks passed
@TerryHowe

Copy link
Copy Markdown
Member

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.

Tagged.Tags() sorts the shared slice under a read lock

2 participants