{"record":{"id":"d44536a8f86dd551","repo":"phacility/phabricator","slug":"encountered-loop-while-following-redirects","errorCode":null,"errorMessage":"Encountered loop while following redirects.","messagePattern":"Encountered loop while following redirects\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/files/storage/PhabricatorFile.php","lineNumber":653,"sourceCode":"        if ($status->isRedirect()) {\n          // This is an HTTP 3XX status, so look for a \"Location\" header.\n          $location = null;\n          foreach ($headers as $header) {\n            list($name, $value) = $header;\n            if (phutil_utf8_strtolower($name) == 'location') {\n              $location = $value;\n              break;\n            }\n          }\n\n          // HTTP 3XX status with no \"Location\" header, just treat this like\n          // a normal HTTP error.\n          if ($location === null) {\n            throw $status;\n          }\n\n          if (isset($redirects[$location])) {\n            throw new Exception(\n              pht('Encountered loop while following redirects.'));\n          }\n\n          $redirects[$location] = $location;\n          $current = $location;\n          // We'll fall off the bottom and go try this URI now.\n        } else if ($status->isError()) {\n          // This is something other than an HTTP 2XX or HTTP 3XX status, so\n          // just bail out.\n          throw $status;\n        } else {\n          // This is HTTP 2XX, so use the response body to save the file data.\n          // Provide a default name based on the URI, truncating it if the URI\n          // is exceptionally long.\n\n          $default_name = basename($uri);\n          $default_name = id(new PhutilUTF8StringTruncator())\n            ->setMaximumBytes(64)","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/storage/PhabricatorFile.php#L635-L671","documentation":"Error \"Encountered loop while following redirects.\" thrown in phacility/phabricator.","triggerScenarios":"Thrown at src/applications/files/storage/PhabricatorFile.php:653 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}