Fix ValueError crash when tab-set contains non-tab-item children #258
+75
−5
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.
Fix tab-set crash with invalid children
Fixes #243
Summary
This PR fixes a
ValueError: not enough values to unpack (expected 2, got 1)crash that occurred when a.. tab-set::directive contained invalid content (non-tab-itemchildren).Changes Made
1. Modified
TabSetDirective.run_with_defaults()insphinx_design/tabs.py(lines 38-53):breaktocontinueto warn about ALL invalid children, not just the first onetab_set.childrentab-itemdirectives are preserved in a new list and reassigned2. Added defensive validation in
TabSetHtmlTransform.run()insphinx_design/tabs.py(lines 247-256):tab-itemchildren that may have slipped throughtab-itemhas exactly 2 children before unpacking3. Added comprehensive test in
tests/test_misc.py:Behavior After Fix
✅ Before: Sphinx-design crashed with
ValueErrorwhen encountering invalid content in a tab-set✅ After: Sphinx-design logs warnings for each invalid child and continues to render valid tab-items
Example input with invalid content:
Result: Both valid tabs (A and B) render correctly, and a warning is logged for the invalid "foo" content.
Visual Verification
The fix was manually tested with a document containing invalid content between tab items:
All three valid tab items render and function correctly despite invalid content in the source.
Tests
All 110 tests pass, including the new test specifically for this issue:
test_tab_set_with_invalid_children- New test reproducing and validating the fixChecklist
TabSetDirective.run_with_defaults()to filter invalid childrenTabSetHtmlTransform.run()Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.