phacility/phabricator · error · Exception
Encountered loop while following redirects.
Error message
Encountered loop while following redirects.
What it means
Raised in PhabricatorFile::newFromFileDownload() while following HTTP redirects: the same Location URL was seen twice, indicating a redirect loop. The download aborts rather than spinning forever; the faulting input is the target URL's redirect chain.
Solutions
- Identify and use the final non-redirecting URL directly
- Repair the remote endpoint's redirect configuration
- Consider pinning a versioned asset URL that does not redirect
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/applications/files/storage/PhabricatorFile.php:653 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/d44536a8f86dd551.
Report an issue: GitHub.
Appendix: source
Thrown at src/applications/files/storage/PhabricatorFile.php:653
if ($status->isRedirect()) {
// This is an HTTP 3XX status, so look for a "Location" header.
$location = null;
foreach ($headers as $header) {
list($name, $value) = $header;
if (phutil_utf8_strtolower($name) == 'location') {
$location = $value;
break;
}
}
// HTTP 3XX status with no "Location" header, just treat this like
// a normal HTTP error.
if ($location === null) {
throw $status;
}
if (isset($redirects[$location])) {
throw new Exception(
pht('Encountered loop while following redirects.'));
}
$redirects[$location] = $location;
$current = $location;
// We'll fall off the bottom and go try this URI now.
} else if ($status->isError()) {
// This is something other than an HTTP 2XX or HTTP 3XX status, so
// just bail out.
throw $status;
} else {
// This is HTTP 2XX, so use the response body to save the file data.
// Provide a default name based on the URI, truncating it if the URI
// is exceptionally long.
$default_name = basename($uri);
$default_name = id(new PhutilUTF8StringTruncator())
->setMaximumBytes(64)View on GitHub (pinned to 5720a38cfe)