{"record":{"id":"29a8bd3ba58a57be","repo":"BookStackApp/BookStack","slug":"http-request-failed-during-discovery-with-error","errorCode":null,"errorMessage":"HTTP request failed during discovery with error: {$exception->getMessage()}","messagePattern":"HTTP request failed during discovery with error: (.+?)","errorType":"exception","errorClass":"OidcIssuerDiscoveryException","httpStatus":null,"severity":"error","filePath":"app/Access/Oidc/OidcProviderSettings.php","lineNumber":106,"sourceCode":"            }\n        }\n    }\n\n    /**\n     * Discover and autoload settings from the configured issuer.\n     *\n     * @throws OidcIssuerDiscoveryException\n     */\n    public function discoverFromIssuer(ClientInterface $httpClient, Repository $cache, int $cacheMinutes): void\n    {\n        try {\n            $cacheKey = 'oidc-discovery::' . $this->issuer;\n            $discoveredSettings = $cache->remember($cacheKey, $cacheMinutes * 60, function () use ($httpClient) {\n                return $this->loadSettingsFromIssuerDiscovery($httpClient);\n            });\n            $this->applySettingsFromArray($discoveredSettings);\n        } catch (ClientExceptionInterface $exception) {\n            throw new OidcIssuerDiscoveryException(\"HTTP request failed during discovery with error: {$exception->getMessage()}\");\n        }\n    }\n\n    /**\n     * @throws OidcIssuerDiscoveryException\n     * @throws ClientExceptionInterface\n     */\n    protected function loadSettingsFromIssuerDiscovery(ClientInterface $httpClient): array\n    {\n        $issuerUrl = rtrim($this->issuer, '/') . '/.well-known/openid-configuration';\n        $request = new Request('GET', $issuerUrl);\n        $response = $httpClient->sendRequest($request);\n        $result = json_decode($response->getBody()->getContents(), true);\n\n        if (empty($result) || !is_array($result)) {\n            throw new OidcIssuerDiscoveryException(\"Error discovering provider settings from issuer at URL {$issuerUrl}\");\n        }\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/app/Access/Oidc/OidcProviderSettings.php#L88-L124","documentation":"discoverFromIssuer() wraps any PSR-18 ClientExceptionInterface raised while fetching the discovery document or JWKS into an OidcIssuerDiscoveryException with this message. It means the HTTP request itself failed at the transport/client level (connection refused, DNS failure, TLS error, timeout) — not that the document content was invalid.","triggerScenarios":"GET {issuer}/.well-known/openid-configuration (or the jwks_uri fetch inside it) throws: unresolvable hostname, connection refused/reset, SSL certificate verification failure, or the 5-second HTTP client timeout in OidcService expiring. Also raised when the cache closure rethrows ClientExceptionInterface.","commonSituations":"BookStack container cannot reach the IdP (firewall, Docker network, internal-only DNS); self-signed certificate not in the CA bundle; IdP briefly down or slow, exceeding the 5s timeout; typo in the issuer host.","solutions":["From the BookStack host, curl the discovery URL printed in the message to reproduce the network failure.","Fix DNS/routing/firewall so the issuer host is reachable; if in Docker, attach the container to the correct network or use a resolvable name.","For self-signed/internal CAs, trust the CA in the container's CA bundle (update-ca-certificates) or configure Guzzle cacert options.","Check the IdP is up and responding within the timeout; investigate IdP logs if requests hang.","Clear the cache entry 'oidc-discovery::<issuer>' and retry after fixing connectivity."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"$discoveryUrl = rtrim(config('oidc.issuer'), '/') . '/.well-known/openid-configuration';\n$ch = curl_init($discoveryUrl);\ncurl_setopt($ch, CURLOPT_NOBODY, true);\ncurl_setopt($ch, CURLOPT_TIMEOUT, 5);\nif (curl_exec($ch) === false) {\n    Log::error('Cannot reach IdP discovery URL: ' . curl_error($ch));\n}\ncurl_close($ch);","typeGuard":null,"tryCatchPattern":"try {\n    $settings->discoverFromIssuer($client, $cache, 15);\n} catch (OidcIssuerDiscoveryException $e) {\n    Log::error('OIDC discovery HTTP failure: ' . $e->getMessage());\n    // fall back to manually configured endpoints or abort login with a clear message\n}","preventionTips":["Verify IdP reachability from the app host (DNS, firewall, Docker network) before enabling OIDC.","Trust internal CAs in the container's CA bundle to avoid TLS verification failures.","Keep the IdP's discovery endpoint fast; note the library uses a 5s HTTP timeout.","Clear oidc-discovery cache keys after connectivity fixes."],"tags":["network","discovery","http-client","oidc"],"backgroundTag":"connection-refused","analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}