-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: resolve IndexError in decompress_list for empty input #3031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Vansh0204
wants to merge
8
commits into
Netflix:master
Choose a base branch
from
Vansh0204:fix/3017-decompress-list-indexerror
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9a5afaa
fix: resolve IndexError in decompress_list for empty input
Vansh0204 b06b515
Merge branch 'master' into fix/3017-decompress-list-indexerror
Vansh0204 d2379f1
address feedback: narrow guard to empty string and add regression tests
Vansh0204 3d7cf8c
address additional feedback: document ambiguity and add happy-path tests
Vansh0204 81cb7f1
test: refine compress_list tests based on review feedback
Vansh0204 598ded2
test: refine compress_list tests based on review feedback part 2
Vansh0204 f399208
fix: resolve black formatting issues in test_util.py
Vansh0204 4fef21f
Merge branch 'master' into fix/3017-decompress-list-indexerror
Vansh0204 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| from metaflow.util import compress_list, decompress_list | ||
|
|
||
|
|
||
| def test_compress_decompress_empty_list(): | ||
| # round-trip must not raise and must return [] | ||
| assert decompress_list(compress_list([])) == [] | ||
|
|
||
|
|
||
| def test_decompress_empty_string(): | ||
| # direct empty-string input | ||
| assert decompress_list("") == [] | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def test_compress_decompress_single_element(): | ||
| lst = ["abc"] | ||
| assert decompress_list(compress_list(lst)) == lst | ||
|
|
||
|
|
||
| def test_compress_decompress_plain_csv(): | ||
| lst = ["a", "b", "c"] | ||
| assert decompress_list(compress_list(lst)) == lst | ||
|
|
||
|
|
||
| def test_compress_decompress_prefix_encoded(): | ||
| # Test with a longer list that triggers prefix encoding if applicable | ||
| # or just test with a manual prefix string | ||
| # Prefix encoding (Mode 2) | ||
| lst = ["test_1", "test_2", "test_3"] | ||
| # Round-trip test for a list with a shared prefix ("test_") - tests Mode 2 indirectly | ||
| compressed = compress_list(lst) | ||
| assert decompress_list(compressed) == lst | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def test_compress_decompress_zlib(): | ||
| # Test with a very long list to trigger zlib compression (Mode 3) | ||
| lst = [str(i) for i in range(1000)] | ||
| compressed = compress_list(lst) | ||
| ZLIB_MARKER = "!" | ||
| assert compressed.startswith(ZLIB_MARKER) | ||
| assert decompress_list(compressed) == lst | ||
|
|
||
|
|
||
| def test_compress_empty_string_element_ambiguity(): | ||
| # Document the current behavior/limitation: | ||
| # both [] and [""] compress to "" | ||
| assert compress_list([]) == "" | ||
| assert compress_list([""]) == "" | ||
| # decompressing "" returns [] | ||
| assert decompress_list("") == [] | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| # Known limitation: round-trip for [""] loses data (returns [] instead of [""]) | ||
| assert decompress_list(compress_list([""])) == [] | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.