fix: return empty JSON for markdown tables with blank headers - #638
fix: return empty JSON for markdown tables with blank headers#638santhreal wants to merge 2 commits into
Conversation
Blank header cells produced an empty CSV for pandas and leaked EmptyDataError from markdown_table_to_json.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe table converter now treats Markdown tables with empty or blank header rows as empty data and returns an empty JSON list. Tests cover single-cell, empty-cell, and multi-column blank-header formats. ChangesEmpty Markdown Table Handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request aims to prevent pandas EmptyDataError when parsing markdown tables with empty header cells by returning an empty DataFrame, and adds corresponding test cases. The review feedback correctly points out that the proposed check not lines[0] is insufficient for tables with three or more empty columns because strip("|") only removes leading and trailing pipes, and suggests a more robust check to handle these cases.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if len(lines) < 2 or not lines[0]: | ||
| return pd.DataFrame() |
There was a problem hiding this comment.
The current check 'not lines[0]' only detects empty headers for tables with 1 or 2 columns. For tables with 3 or more columns (e.g., '| | | |'), 'lines[0]' will be evaluated as '|' (or containing multiple pipes) because 'strip("|")' only removes the leading and trailing pipes. As a result, 'not lines[0]' evaluates to False, and the function will still attempt to parse the table and return non-empty JSON with 'Unnamed' keys, which contradicts the PR's objective of returning empty JSON for tables with blank headers.\n\nTo ensure consistent behavior across any number of columns, we should check if the header line contains only pipes and whitespace.
if len(lines) < 2 or not lines[0].replace('|', '').strip():\n return pd.DataFrame()strip("|") only clears leading/trailing pipes, so "| | | |" still looked non-empty and produced Unnamed columns.
markdown_table_to_json hits EmptyDataError when |\n|-|. This PR fixes the regression with a focused test covering the case.
Summary by CodeRabbit