Skip to content

test: show full error message on test failure#1364

Merged
sbryngelson merged 1 commit intomasterfrom
fix/test-error-truncation
Apr 9, 2026
Merged

test: show full error message on test failure#1364
sbryngelson merged 1 commit intomasterfrom
fix/test-error-truncation

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

Summary

  • Removes the 300-character hard truncation of exception messages in the test runner (handle_case in toolchain/mfc/test/test.py)
  • The limit was cutting off valuable diagnostic info on tolerance failures — e.g. the rel: value in the tolerance line was being truncated to re...
  • Error messages from the test framework are already concise and well-structured, so truncation adds no value

Test plan

  • Run a test with a known golden file mismatch and verify the full tolerance info (both abs: and rel:) is displayed in the failure output

Remove 300-character truncation of exception messages in the test
runner. The limit was cutting off valuable diagnostic info — e.g.
the tolerance's rel: value — making failures harder to diagnose.
@sbryngelson sbryngelson marked this pull request as ready for review April 9, 2026 20:21
@sbryngelson sbryngelson merged commit 9c0394a into master Apr 9, 2026
33 of 70 checks passed
@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Apr 9, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@sbryngelson sbryngelson deleted the fix/test-error-truncation branch April 9, 2026 20:21
@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Apr 9, 2026

Code Review by Qodo

🐞 Bugs (1)   📘 Rule violations (0)   📎 Requirement gaps (0)   🎨 UX Issues (0)
🐞\ ☼ Reliability (1)

Grey Divider


Action required

1. Markup-parsed error crashes 🐞
Description
In handle_case, the exception message is printed through Rich with markup parsing enabled, so
exception strings containing [/] can be interpreted as markup and raise a Rich rendering error
while reporting the failure. This can interrupt the test runner’s failure reporting and hide the
original test error.
Code

toolchain/mfc/test/test.py[614]

+            cons.print(f"    Error: {exc}")
Evidence
cons ultimately prints via rich.console.Console.print() with no markup=False or escaping, so
arbitrary exception text is treated as Rich markup. handle_case prints {exc} on failure, and
test execution uses subprocess.run via common.system, which can surface non-MFC exceptions whose
string form may include bracketed segments that are unsafe under markup parsing.

toolchain/mfc/test/test.py[602-618]
toolchain/mfc/printer.py[7-40]
toolchain/mfc/common.py[62-70]
toolchain/mfc/test/case.py[166-187]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`handle_case` prints exception text via Rich markup parsing. If the exception message contains `[` / `]` sequences, Rich may interpret them as markup and raise during printing, masking the original test failure.

## Issue Context
The printer wrapper uses `rich.console.Console()` and forwards strings to `Console.print()` without escaping, so markup parsing is on by default.

## Fix Focus Areas
- toolchain/mfc/test/test.py[609-616]
- toolchain/mfc/printer.py[7-40]

## Suggested change
Print the error line with markup disabled (or escape the exception text). For example:
- `cons.print(f"    Error: {exc}", markup=False)`

Optionally preserve formatting for your own exceptions only:
- `cons.print(f"    Error: {exc}", markup=isinstance(exc, MFCException))`
(or escape only when not an `MFCException`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8e106eee-4643-424f-a656-d25780d3fbaf

📥 Commits

Reviewing files that changed from the base of the PR and between f6f5c85 and 4f72c47.

📒 Files selected for processing (1)
  • toolchain/mfc/test/test.py

📝 Walkthrough

Walkthrough

The change modifies how exceptions are displayed in error output. Previously, exception strings were explicitly truncated to 300 characters before being printed. The update removes this truncation logic and instead prints the full exception object directly. The exception string is still converted to lowercase and used for hint logic and error categorization downstream, so the control flow and decision-making remain unchanged—only the display formatting behavior is altered.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

if len(exc_str) > 300:
exc_str = exc_str[:297] + "..."
cons.print(f" Error: {exc_str}")
cons.print(f" Error: {exc}")
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.

Action required

1. Markup-parsed error crashes 🐞 Bug ☼ Reliability

In handle_case, the exception message is printed through Rich with markup parsing enabled, so
exception strings containing [/] can be interpreted as markup and raise a Rich rendering error
while reporting the failure. This can interrupt the test runner’s failure reporting and hide the
original test error.
Agent Prompt
## Issue description
`handle_case` prints exception text via Rich markup parsing. If the exception message contains `[` / `]` sequences, Rich may interpret them as markup and raise during printing, masking the original test failure.

## Issue Context
The printer wrapper uses `rich.console.Console()` and forwards strings to `Console.print()` without escaping, so markup parsing is on by default.

## Fix Focus Areas
- toolchain/mfc/test/test.py[609-616]
- toolchain/mfc/printer.py[7-40]

## Suggested change
Print the error line with markup disabled (or escape the exception text). For example:
- `cons.print(f"    Error: {exc}", markup=False)`

Optionally preserve formatting for your own exceptions only:
- `cons.print(f"    Error: {exc}", markup=isinstance(exc, MFCException))`
(or escape only when not an `MFCException`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.91%. Comparing base (23bbd4f) to head (4f72c47).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1364      +/-   ##
==========================================
+ Coverage   64.88%   64.91%   +0.02%     
==========================================
  Files          70       70              
  Lines       18251    18251              
  Branches     1508     1508              
==========================================
+ Hits        11842    11847       +5     
+ Misses       5446     5441       -5     
  Partials      963      963              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant