Skip to content

[claude] Refuse hgweb diff pages too large to render - #2873

Open
myieye wants to merge 1 commit into
developfrom
claude/hgweb-diffguard
Open

myieye wants to merge 1 commit into
developfrom
claude/hgweb-diffguard

Conversation

@myieye

@myieye myieye commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

[Claude, autonomous]

A user opening a large changeset diff in hgweb blew the pod's memory. hgweb keeps a file's whole diff in memory while rendering and diffs the changeset twice (diffstat), and Mercurial has no cap for this. The new diffguard extension sizes the files a page would diff from the revlog index; over diffguard.maxbytes (32 MB before+after) the changeset page is served without the diff (file list and per-file links still work) and the single-file diff/comparison/annotate pages answer 403.

  • Measured on the published image: a 26 MB file rewrite peaked at ~320 MB RSS and a 45 MB rewrite got the mod_wsgi daemon OOM-killed in a 600 MiB cgroup; with the guard both pages return in under a second.
  • Peak RSS is roughly 6-8x the bytes touched, so 32 MB caps a request at ~250 MB. Tune in hgweb.hgrc ([diffguard] maxbytes, 0 disables).
  • Tested with Mercurial 6.3.2 (the image's version) against all hgweb styles, the json-lex log Lexbox uses, removed/added files, bad revisions and missing files; those paths behave as before.
  • Deploy order is safe: if the configmap lands before the image, hg logs a failed-extension warning and serves normally.

Generated by Claude Code

hgweb holds a file's whole diff in memory while rendering and diffs the
changeset twice (diffstat). Measured on the published image, a changeset
rewriting a 45 MB file got the mod_wsgi daemon OOM-killed inside a 600 MiB
cgroup, taking every in-flight Send/Receive request with it. Mercurial has
no built-in cap for this, so add a small extension that sizes the files a
page would diff from the revlog index and, over diffguard.maxbytes (32 MB),
serves the changeset page without the diff and answers 403 on the
single-file pages.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AM78WDGRwYjhxtfmrFr3az
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 21d2f076-e254-47f7-94ac-9f2f32c7a82e
Commits

Reviewing files that changed from the base of the PR and between 5efc48f and 1aa4ee7.

Files selected for processing: 3
  • hgweb/Dockerfile
  • hgweb/diffguard.py
  • hgweb/hgweb.hgrc
  • Autofix · 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.

@github-actions github-actions Bot added the 📦 Lexbox issues related to any server side code, fw-headless included label Oct 30, 2026

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

📦 Lexbox issues related to any server side code, fw-headless included

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants