bug: decompress_list raises IndexError on empty string input

Open Beginner friendly
#3,017 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in metaflow/util.py around line 387, where decompress_list accesses the first character of its input. Reproduce the failure with decompress_list(compress_list([])) and verify that the empty-list round trip returns [] without raising IndexError. Done means the valid empty-string input is handled and the existing non-empty behavior remains intact.

Written by the indexing model from the issue text.

Description

Bug Report

File: metaflow/util.py, line 387

Summary

compress_list([]) legitimately returns "" (joining an empty list).
However, decompress_list("") immediately crashes with IndexError
because lststr[0] is accessed with no guard for empty input.

This makes the natural round-trip decompress_list(compress_list([]))
crash, breaking the contract that these two functions are inverses of
each other.

Reproducer

from metaflow.util import compress_list, decompress_list

print(compress_list([]))            # returns ""
decompress_list(compress_list([]))  # IndexError: string index out of range

Stack trace
File "metaflow/util.py", line 387, in decompress_list
if lststr[0] == zlibmarker:

IndexError: string index out of range

**Expected behavior**

`decompress_list(compress_list([]))` returns `[]`.

**Actual behavior**

`IndexError: string index out of range` at `lststr[0]`.

**Root cause**

Line 387 accesses `lststr[0]` with no guard for empty string.
An empty task ID list is a valid real-world state.

**Environment**
- Metaflow: latest master
- Python: 3.11+
Dominant language
Python
Stars
10.3k
Forks
1.4k
Avg merge
3d 1h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Netflix/metaflow

All issues in Netflix/metaflow

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.