Skip to content

fix: guard unstarted TTY tracking and pass fetcher to TTYCopyHandler - #2332

Merged
TerryHowe merged 1 commit into
oras-project:mainfrom
Hrushikesh-ramilla:fix/tty-status-handler-safety
Nov 15, 2026
Merged

TerryHowe merged 1 commit into
oras-project:mainfrom
Hrushikesh-ramilla:fix/tty-status-handler-safety

Conversation

@Hrushikesh-ramilla

Copy link
Copy Markdown
Contributor

Relates to #2280

All six TTY status handlers in cmd/oras/internal/display/status/tty.go (TTYPushHandler, TTYPullHandler, TTYCopyHandler, TTYBackupHandler, TTYRestoreHandler, TTYBlobPushHandler) dereferenced tracked without checking if tracking had started, so calling methods like StopTracking, OnCopySkipped, PostCopy, OnMounted, OnNodeRestored, OnNodeSkipped, or OnBlobExists before TrackTarget/StartTracking panicked instead of returning an error.

In addition, NewTTYCopyHandler did not take a content.Fetcher, so TTYCopyHandler.PostCopy passed ch.tracked to graph.FilteredSuccessors instead of a configured fetcher like TextCopyHandler, TTYPushHandler, TTYBackupHandler, and TTYRestoreHandler.

This guards nil tracked access across all six handlers via shared helpers (reportTracked, closeTracked, reportSkippedSuccessors) returning status tracking has not started, updates NewTTYCopyHandler and display.NewCopyHandler to pass fetcher into TTYCopyHandler, and adds regression tests in tty_test.go. Verified locally with go vet ./... and go test -race -count=1 -skip containersConfigFullStack ./... (skipping the two Linux-specific certs.d colon directory tests on Windows).

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?

@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

@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.54%. Comparing base (02ffd9d) to head (2499c59).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2332      +/-   ##
==========================================
+ Coverage   73.51%   73.54%   +0.02%     
==========================================
  Files         157      157              
  Lines        6582     6574       -8     
==========================================
- Hits         4839     4835       -4     
+ Misses       1454     1450       -4     
  Partials      289      289              

☔ 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 merged commit 821dd38 into oras-project:main Nov 15, 2026
10 checks passed
@TerryHowe TerryHowe mentioned this pull request Nov 17, 2026
4 tasks done
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.

2 participants