Skip to content

fix(report): escape pipes and line breaks in generator table cells - #1558

Open
napetrov wants to merge 10 commits into
intel:mainfrom
napetrov:arch/r11-3
Open

napetrov wants to merge 10 commits into
intel:mainfrom
napetrov:arch/r11-3

Conversation

@napetrov

@napetrov napetrov commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Markdown table cells in ReportGenerator (Top/Bottom 10, Performance by Topic and Question Source, Failure Analysis) printed question text, question IDs, topic/source labels, diagnosis text and evidence raw. A | added columns to the row; a newline ended it. report/fmt.py gains cell(), which escapes the pipe and turns line breaks into spaces, and every data cell of those tables uses it. Numbers and fixed labels are unchanged.

Evidence

  • tests/test_report_table_cells.py: red before the fix (2 failed, generator.py unfixed), green after; the failure-row test pins the Failure Analysis escapes.
  • make ci-local: the only failure is tests/test_cli_fault_contract.py::test_a_bad_path_is_refused_as_the_quickstart_says[agent run], which fails the same way on the unmodified base. Report-related subset: 2980 passed.
  • Self-review (local mode, 2 passes, L1): no blocking; declined nits are in the local notes.

Other writers

Other writers with unescaped identifier cells (arm, harness, run and model names in arms_report, plugin_delta_report, task_runs_report, subject_report, model_compare, delivery, single_condition_report) are not changed here. Their free text is already escaped; a follow-up can apply fmt.cell to them.

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented Dec 2, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.44%. Comparing base (60948d0) to head (f5bc6fb).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1558      +/-   ##
==========================================
- Coverage   96.45%   96.44%   -0.01%     
==========================================
  Files         575      575              
  Lines       75872    75902      +30     
  Branches    13076    13080       +4     
==========================================
+ Hits        73179    73204      +25     
  Misses       1644     1644              
- Partials     1049     1054       +5     
Files with missing lines Coverage Δ
dokimi/dokimi/report/fmt.py 100.00% <100.00%> (ø)
dokimi/dokimi/report/generator.py 95.67% <100.00%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

⚠️ Tests miss 6 of 35 small breaks of the lines this PR changes

At f5bc6fb: 29 caught · 6 missed

Each row is a small deliberate break (a mutant) of a line this PR changes that every test reaching that line still passes. Add a test that fails on it or, if it cannot change behaviour, put # mutation-ok[<operator>]: <reason> at the end of the line or alone on the line above.

Where Operator Change no test notices Tests reaching the line
dokimi/dokimi/report/fmt.py:30 drop-clause len(state.tokens) > first_token and state.tokens[-1].type == "code_inline" → (len(state.tokens) > first_token) 6
dokimi/dokimi/report/fmt.py:47 drop-clause "`" not in text or r"\|" not in text → ("`" not in text) 31
dokimi/dokimi/report/fmt.py:47 drop-clause "`" not in text or r"\|" not in text → (r"\|" not in text) 31
dokimi/dokimi/report/generator.py:534 drop-clause e.get('delta') or 0 → (e.get('delta')) 5
dokimi/dokimi/report/generator.py:534 bump-int 0 → 1 5
dokimi/dokimi/report/fmt.py:47 swap-boolop "`" not in text or r"\|" not in text → '`' not in text and '\\|' not in text 31

Not checked:

  • 5 changed lines were not mutated

Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary.

A question text, question ID or topic label with a raw `|` added columns
to its Markdown row, and a line break ended the row early. Add fmt.cell
and apply it to every data cell of the ReportGenerator tables.

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…them

Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov
napetrov marked this pull request as ready for review December 5, 2026 05:27
@napetrov
napetrov requested a review from a team as a code owner December 5, 2026 05:27
Copilot AI balanced review requested due to automatic review settings December 5, 2026 05:27
@napetrov napetrov changed the title [stacked on #1525] fix(report): escape pipes and line breaks in generator table cells fix(report): escape pipes and line breaks in generator table cells Dec 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block approval of the Markdown table-cell escaping changes.

No open issues 🎉

What changed in this PR

0 new findings; nothing to fix.

This PR protects ReportGenerator Markdown tables from pipes and line breaks in text values.

Changes:

  • Adds a shared table-cell formatter.
  • Applies escaping to question, topic/source, and failure-analysis tables.
  • Adds regression tests and a changelog entry.
File Description
dokimi/​tests/​test_report_table_cells.py Tests escaping and consistent row widths.
dokimi/​dokimi/​report/​generator.py Escapes text cells in affected tables.
dokimi/​dokimi/​report/​fmt.py Adds cell() to escape pipes and normalize line breaks.
dokimi/​changelog.d/​20261202_120000_napetrov_report-table-cell-escape.md Documents the table-formatting fix.

Review effort: Balanced

@exai-bot

exai-bot commented Dec 5, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 4 selected item(s).

CI at f5bc6fb: 21 passing, 4 skipped.

Review details
  • Commit reviewed: f5bc6fb against merge base 60948d0
  • Coverage: 4 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 95k tokens (45k from cache), 1m11s
  • Tool calls: 8 (4 file_read, 2 code_search, 1 ci_status, 1 local_check_results)
  • Report table cell escaping, generation, tests, and changelog: 4 files

Comment thread dokimi/dokimi/report/fmt.py Resolved
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87ACFvu
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

@antonwolfy antonwolfy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. cell() keeps the rows intact for every case I tried, including the backslash-before-pipe case exai-bot raised, which the last commit fixed. One nit on a test gap.

What I ran, on a Linux review host at ec4394c:

  • make ci-local: 38 passed, 0 failed, 16 skipped (matrix legs on other Pythons and semgrep are not run locally).
  • Reproductions of cell() through markdown-it with the table rule on, for a\|b, a|b, code spans with and without \|, an unclosed backtick, double-backtick spans, a trailing backslash, and line breaks inside a code span: every row keeps three cells and shows the original text.
  • A mutation check of the new tests (below).

Checked, no issues

  • Pipes and backslashes: a\|b becomes a\\\|b and renders as a\|b in one cell; code spans render their pipe literally.
  • Dependency: markdown-it-py is already a runtime dependency in dokimi/pyproject.toml.
  • Scope: the PR text says the other report writers are left for a follow-up, and the diff matches that.
  • DCO and changelog: all three non-merge commits carry Signed-off-by, and the fragment is present.

Comment thread dokimi/dokimi/report/fmt.py Resolved

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@napetrov, could you fix the small thing I've marked fix before merge (in the line comments) and fix what antonwolfy's thread on dokimi/dokimi/report/fmt.py:57 still points out? I'll approve once that's done.
I'll approve once that's done.

What I checked on ec4394c:

  • When I changed the code on purpose, the tests still passed for 2 of 12 changes, and no test pins this one down yet (non-blocking): dokimi/dokimi/report/generator.py:512 (the call is dropped).
  • The 8 changed tests pass, and fail on main as expected.
  • The full test suite passes with main merged in (36,076 tests), apart from failures main has too.
  • It merges cleanly onto main.

Comment thread dokimi/dokimi/report/fmt.py Resolved
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87AFVBg
Thread: PRR_kwDOVBg7g88AAAABcbSj7Q
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87ALTgY
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRR_kwDOVBg7g88AAAABceUI-w
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

napetrov commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by antonwolfy

One nit on a test gap.
Covered in 24acaee and replied to inline.

@napetrov

napetrov commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

no test pins this one down yet (non-blocking)
0cb2b98 tests diagnosis descriptions. Both inline nits have replies.

@napetrov

napetrov commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

All 11 table-cell tests pass. Each new case fails when its corresponding mutation from the reviews is applied.

@vchamarthi vchamarthi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@napetrov, could you fix the small thing I've marked fix before merge (in the line comments)? I'll approve once that's done.

What I checked on 0cb2b98:

  • When I changed the code on purpose, the tests still passed for 1 of 12 changes, and no test pins this one down yet (non-blocking): dokimi/dokimi/report/fmt.py:32 (it returns None).
  • The 11 changed tests pass, and fail on main as expected.
  • The full test suite passes with main merged in (36,229 tests), apart from failures main has too.
  • It merges cleanly onto main.

Comment thread dokimi/tests/test_report_table_cells.py Resolved
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87AMkpl
Thread: PRR_kwDOVBg7g88AAAABcfElzw
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
@napetrov

napetrov commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

Re: review by vchamarthi

no test pins this one down yet (non-blocking)
f5bc6fb catches return None.

@napetrov

napetrov commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

cell() has a direct test for a code span followed by a trailing unmatched backtick in f5bc6fb. The test reproduces the IndexError with return None and passes with the rule restored. All 12 table-cell tests pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants