Skip to content

Escape NUL bytes in white diff admin text. - #1

Closed
HyperSoWeak wants to merge 1 commit into
mainfrom
fix/whitediff-nul-byte
Closed

HyperSoWeak wants to merge 1 commit into
mainfrom
fix/whitediff-nul-byte

Conversation

@HyperSoWeak

@HyperSoWeak HyperSoWeak commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

NUL is valid UTF-8, so backslashreplace leaves it as-is in the white diff
admin_text. PostgreSQL rejects NUL in text columns, so writing the
evaluation fails, and EvaluationService retries it forever, leaving the
testcase unscored. Triggered by a contestant printing a NUL byte on a
mismatching line (e.g. uninitialized memory) in a Batch task with the
built-in diff.

The fix escapes NUL as \x00 instead of stripping it, so the difference
stays visible.

Regression from b98e44b, not in any release. Similar to cms-dev#888. Hit this in
production during an exam.

NUL is valid UTF-8, so decoding with backslashreplace keeps it as-is.
PostgreSQL rejects NUL in text columns, so writing the evaluation fails
and EvaluationService retries it forever, leaving the testcase
unscored. Escape it as \x00, consistent with how backslashreplace
renders invalid bytes, so the admin can still see the difference.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 54be4856-a3f2-4df2-b5ef-0c1a226c1c58
📥 Commits

Reviewing files that changed from the base of the PR and between cc9dfaf and c7c81c3.

📒 Files selected for processing (2)
  • cms/grading/steps/whitediff.py
  • cmstestsuite/unit_tests/grading/steps/whitediff_test.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

_white_diff now escapes NUL characters in mismatch text as the literal \x00. A unit test checks that the mismatch is reported and the admin text contains no raw NUL byte.

Changes

Mismatch text escaping

Layer / File(s) Summary
Escape NUL characters in mismatch output
cms/grading/steps/whitediff.py, cmstestsuite/unit_tests/grading/steps/whitediff_test.py
_white_diff replaces decoded NUL characters in both displayed lines with the literal \x00. The test verifies that a NUL byte causes a mismatch and appears escaped in the admin text.

Priority: ⬆️ High

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c7c81

NULs in mismatch diagnostics are displayed as visible text, and no merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: escaping NUL bytes in white diff admin text.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@HyperSoWeak

Copy link
Copy Markdown
Owner Author

Superseded by cms-dev#1726.

@HyperSoWeak HyperSoWeak closed this Oct 5, 2026
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.

1 participant