Skip to content

fix: handle empty show line results#501

Merged
shcheklein merged 1 commit into
iterative:mainfrom
w3lld1:fix/344-empty-show-line-output
Jul 9, 2026
Merged

fix: handle empty show line results#501
shcheklein merged 1 commit into
iterative:mainfrom
w3lld1:fix/344-empty-show-line-output

Conversation

@w3lld1

@w3lld1 w3lld1 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #344 by making gto show <artifact>#<missing-stage> --version return an empty successful output instead of raising list index out of range when the underlying show result is empty.

Changes

  • Guard show line-format output before indexing into an empty table result.
  • Preserve the existing Cannot apply --<arg> validation for non-empty results that do not support the requested line flag.
  • Add a regression test for an empty show --version result.

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 -q
  • pytest -q
    • 189 passed, 1 warning
  • python -m py_compile gto/*.py
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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/--ref line 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 ... --version returns 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.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@shcheklein
shcheklein merged commit 6ec2a2b into iterative:main Jul 9, 2026
16 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.

gto show gives list index out of range error when supplied with --version

4 participants