to_compound raises IndexError for an empty list
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in cq_editor/cq_utils.py:52-60 and run the provided to_compound([]) reproduction to confirm the indexing failure. Define and document the empty-list result before the first-element access, then add regression coverage for empty, one-element, and multi-element lists and verify the GUI or export path does not raise IndexError.
Written by the indexing model from the issue text.
Description
Summary
to_compound() checks whether the input is a list and then reads obj[0] before handling the empty-list case. Empty selections or empty intermediate results therefore raise IndexError in a GUI conversion path instead of returning a defined empty result or a diagnostic error.
Code path
cq_editor/cq_utils.py:52-60: the first list element is read before the empty-list branch.- The function is used by object-tree display/export paths that can receive an empty result.
Steps to reproduce
The minimal boundary input is an empty list:
from cq_editor.cq_utils import to_compound
to_compound([])
On the checked source revision this reaches the obj[0] access and raises IndexError.
Expected behavior
An empty list should have an explicit, documented result (for example, an empty compound or a clear conversion error) and should not fail with an indexing exception.
Actual behavior
The function indexes an empty list before it can decide how to represent an empty result.
Existing coverage
Issues #211 and #261 concern other Workplane/export failures, but neither identifies this obj[0] root cause. No exact fix was found.
Suggested fix
Define the empty-list behavior before indexing and add a regression test for an empty selection/export result.
Suggested tests
to_compound([]).- A normal one-element list.
- A normal multi-element list.
- Empty GUI selection or empty export result.
Submitted with Codex.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 210
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CadQuery/CQ-editor
-
Difficulty 2/5 Half a day Newbie friendliness 78/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Crash on render Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in CadQuery/CQ-editor
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100