Skip to content

Return a sorter from NewSorter - #2112

Merged
henry118 merged 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/new-sorter-returns-a-transformer
Oct 1, 2026
Merged

henry118 merged 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/new-sorter-returns-a-transformer

Conversation

@v0ropaev

Copy link
Copy Markdown
Contributor

Description

transform.NewSorter() returns nil:

type sorter struct{}

var _ Transformer = (*sorter)(nil)

// NewSorter creates a transformer that sorts container edits.
func NewSorter() Transformer {
	return nil
}

pkg/ is public, and the constructor is the only way to reach sorter from outside the package, so an external caller gets a nil Transformer and panics on the first Transform call.

Nothing in the tree notices. NewSimplifier composes sorter{} directly (simplify.go:31-37), and sorter_test.go constructs sorter{} directly in all three of its tests, so the constructor has no caller anywhere in the repo. grep -rn NewSorter outside vendor/ returns only its own definition and doc comment.

This has been there since the file was added in #1784.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Unit tests passing (make test)
  • Lint checks passing (make lint) — golangci-lint is not installed here; gofmt -s -l on the package is clean
  • Test cases are added for new code paths
  • Commits are signed-off — DCO yes, not GPG signed

Testing

TestNewSorterReturnsAUsableTransformer asserts the constructor gives something non-nil and that it actually sorts: two devices out of order in, gpu0 before gpu1 out. On current main it fails at the nil check, which is the panic an outside caller would hit.

go test ./pkg/nvcdi/...   all ok

darwin/arm64, Go 1.27.1, no GPU.

NewSorter returns nil, so the only way an outside caller can reach the
sorter hands back a nil Transformer and the first Transform call panics.
Everything else in the file is implemented, sorter satisfies Transformer
(the assertion right above says so), NewSimplifier composes sorter{}
directly and the tests construct sorter{} directly, so nothing in the tree
goes through the constructor and nothing caught it.

Return sorter{}, and cover the constructor.

Signed-off-by: Dmitry Voropaev <dy.voropaev@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@henry118 henry118 self-assigned this Sep 30, 2026
@henry118

Copy link
Copy Markdown
Member

@v0ropaev thanks for the patch. please cryptographically sign the commit. and i'll trigger the CI once it's done. thanks

@v0ropaev
v0ropaev force-pushed the fix/new-sorter-returns-a-transformer branch from f57b76f to 0aabe0b Compare October 1, 2026 21:24
@v0ropaev

v0ropaev commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Done, the commit is signed and GitHub marks it verified. Ready for CI whenever you want to kick it off.

@henry118

henry118 commented Oct 1, 2026

Copy link
Copy Markdown
Member

/ok to test 0aabe0b

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 36928530525

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.02%) to 44.622%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 13554
Covered Lines: 6048
Line Coverage: 44.62%
Coverage Strength: 0.45 hits per line

💛 - Coveralls

@henry118
henry118 merged commit a672e37 into NVIDIA:main Oct 1, 2026
21 checks passed
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