fix: handle empty show line results#501
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an IndexError in the gto show CLI when using a line-format flag (e.g. --version) and the underlying table result is empty (such as when querying a missing stage). Instead of crashing, the command now succeeds with empty output, matching the expectation described in issue #344.
Changes:
- Add an empty-result guard before indexing into the table rows when
--name/--version/--stage/--refline output is requested. - Preserve
Cannot apply --<arg>validation for non-empty results where the requested line flag doesn’t exist as a column. - Add a regression test ensuring
show ... --versionreturns success with empty stdout when the show result is empty.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| gto/cli.py | Prevents list index out of range by returning early for empty table row sets in line-format output mode. |
| tests/test_cli.py | Adds a regression test covering empty show --version output behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
shcheklein
approved these changes
Jul 9, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #344 by making
gto show <artifact>#<missing-stage> --versionreturn an empty successful output instead of raisinglist index out of rangewhen the underlying show result is empty.Changes
showline-format output before indexing into an empty table result.Cannot apply --<arg>validation for non-empty results that do not support the requested line flag.show --versionresult.Verification
pytest tests/test_cli.py::test_show_line_flag_empty_result tests/test_cli.py::test_commands tests/test_cli.py::test_show_ref_flag_not_applicable -qpytest -qpython -m py_compile gto/*.pygit diff --check