-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Bug
In src/lib/HgResumeApi.php (line 261 on dockerize branch), $bundleTimeFile is undefined:
if (BundleHelper::bundleOutputHasErrors($asyncRunner->getOutput())) {
$response = new HgResumeResponse(HgResumeResponse::FAIL);
$response->Values = array('Error' => substr(file_get_contents($bundleTimeFile), 0, 1000));
return $response;
}This causes a PHP fatal error when Mercurial bundle creation fails:
PHP Warning: Undefined variable $bundleTimeFile
PHP Fatal error: Uncaught ValueError: Path cannot be empty in file_get_contents()
Why this is rarely seen
This code path only executes when:
- A
pullBundleChunkrequest is made - The async Mercurial bundle creation fails with errors
- The server attempts to report the error back to the client
Normal successful operations never hit this path—it only triggers when something is already wrong (e.g., repository corruption).
Root cause
The variable was defined in API v1 as $bundleTimeFile = $bundle->getBundleTimeFileName(), but was removed during refactoring without updating this error-handling code.
Fix
Replace file_get_contents($bundleTimeFile) with $asyncRunner->getOutput():
$response->Values = array('Error' => substr($asyncRunner->getOutput(), 0, 1000));This matches the pattern used elsewhere in the codebase (e.g., pushBundleChunk).
Discovery context
Encountered while debugging a repository with corruption at changeset 257. The 500 error masked the underlying issue (missing revlog data), making troubleshooting harder.
Troubleshooting the underlying repository corruption
When you see this error, the real problem is usually a corrupted repository. Here's how we fixed it:
- Diagnose with
hg verify:
hg -R /path/to/repo verifyOutput showed:
257: empty or missing SomeFile.xml
SomeFile.xml@257: manifest refers to unknown revision 86f99f857d84
...
6 integrity errors encountered!
(first damaged changeset appears to be 257)- Back up the repository before making changes:
cp -a /path/to/repo /path/to/repo-backup- Strip the corrupted changesets:
hg -R /path/to/repo --config extensions.strip= strip -r 257 --no-backup(We used --no-backup since we'd already made our own backup.)
- Have the client re-push their changes from their local (healthy) copy.