Fix decompress_list IndexError on empty string input - #3356
Open
Anurag-M1 wants to merge 2 commits into
Open
Conversation
Contributor
Greptile SummaryFixes empty-list round trips by making
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| metaflow/util.py | Adds a narrowly scoped empty-string guard that prevents the reported IndexError and restores the compression round-trip invariant. |
| test/unit/test_compress_decompress_list.py | Adds focused regression tests for empty input and representative existing compression modes. |
Reviews (3): Last reviewed commit: "Merge branch 'master' into fix/decompres..." | Re-trigger Greptile
Collaborator
|
It makes fixes for two separate issues. Let's just do a targeted fix of #3017 and then I can run the tests/merge. |
Anurag-M1
force-pushed
the
fix/decompress-list-empty-string
branch
from
August 31, 2026 08:34
d2805c2 to
b379524
Compare
Author
|
Updated as requested! Rebased onto |
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
decompress_list("")crashes withIndexErrorbecauselststr[0]is accessed with no guard for empty input. This breaks the round-trip invariantdecompress_list(compress_list([])) == [].Context / Motivation
compress_list([])legitimately returns""(joining an empty list). However,decompress_list("")immediately crashes at line 387 becauselststr[0]is accessed without checking for empty input first. An empty task ID list is a valid real-world state.Fixes #3017
Changes Made
if lststr == "": return []indecompress_list()before thelststr[0]access== ""(notnot lststr) soNonestill fails loudly — ifNoneslips through, the real bug should be caught upstreamTesting
Added
test/unit/test_compress_decompress_list.pywith 7 test cases:test_compress_empty_listcompress_list([]) == ""test_decompress_empty_stringdecompress_list("") == [](the actual bug)test_roundtrip_emptydecompress_list(compress_list([])) == []test_roundtrip[single]["x"]test_roundtrip[simple]["a", "b", "c"]test_roundtrip[common-prefix]:encodingtest_roundtrip_zlibzlibmin=0All 7 tests pass. Full unit test suite unaffected.
AI Disclosure
AI tools were used to help identify the issue and structure the PR. All code was reviewed and understood before submission.