phacility/phabricator · error · PhutilProxyException
Failed to unserialize XHProf profile!
Error message
Failed to unserialize XHProf profile!
What it means
When rendering an XHProf profile page, Phabricator loads the stored profile file and decodes it with phutil_json_decode(). If the data is not valid JSON, the PhutilJSONParserException is re-thrown wrapped in this PhutilProxyException.
Source
Thrown at src/applications/xhprof/controller/PhabricatorXHProfProfileController.php:25
return true;
}
public function handleRequest(AphrontRequest $request) {
$phid = $request->getURIData('phid');
$file = id(new PhabricatorFileQuery())
->setViewer($request->getUser())
->withPHIDs(array($phid))
->executeOne();
if (!$file) {
return new Aphront404Response();
}
$data = $file->loadFileData();
try {
$data = phutil_json_decode($data);
} catch (PhutilJSONParserException $ex) {
throw new PhutilProxyException(
pht('Failed to unserialize XHProf profile!'),
$ex);
}
$symbol = $request->getStr('symbol');
$is_framed = $request->getBool('frame');
if ($symbol) {
$view = new PhabricatorXHProfProfileSymbolView();
$view->setSymbol($symbol);
} else {
$view = new PhabricatorXHProfProfileTopLevelView();
$view->setFile($file);
$view->setLimit(100);
}
$view->setBaseURI($request->getRequestURI()->getPath());View on GitHub (pinned to 5720a38cfe)
Solutions
- Re-capture the profile with Phabricator's built-in XHProf sampling so the file is JSON in the expected shape.
- Download the file and inspect it (file head) to confirm whether it is truncated or a foreign format.
- Delete the corrupt profile file and regenerate it.
- If serving profile pages programmatically, catch PhutilProxyException/PhutilJSONParserException and render a friendly error or 404 instead of a stack trace.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check profile data before handing it to the profile view
json_decode($file_data, true);
if (json_last_error() !== JSON_ERROR_NONE) {
// render a friendly 'corrupt profile' page or 404 instead of throwing
} Try / catch
try {
$data = phutil_json_decode($file_data);
} catch (PhutilJSONParserException $ex) {
throw new PhutilProxyException(
pht('Failed to unserialize XHProf profile!'),
$ex);
} Prevention
- Only ingest profiles captured by Phabricator's own XHProf sampling pipeline (JSON format).
- Verify file size/hash after upload to catch truncation.
- Serve profile pages through a wrapper that converts decode failures into user-facing errors.
When it happens
Trigger: Requesting /xhprof/profile/PHID-... for a file whose contents are corrupt: truncated upload, binary or PHP-serialized data from an external profiler instead of Phabricator's JSON sample format, or a file that was stored with the wrong content.
Common situations: Profiles pushed into Phabricator Files by scripts from a different XHProf capture pipeline; truncated multipart upload; very old or manually edited profile files; disk/storage corruption.
Related errors
- Configuration file is not properly formatted JSON. %s
- Expected JSON response from Duo.
- Email record has invalid user PHID!
- Use form-encoded data to submit parameters to Conduit endpoi
- The value for parameter '%s' is not valid JSON. All paramete
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/3bafc2beb8dc85b6.
Report an issue: GitHub.