{"record":{"id":"ef21599075415528","repo":"nextcloud/all-in-one","slug":"unexpected-response-from-desec-during-domain-regis","errorCode":null,"errorMessage":"Unexpected response from deSEC during domain registration (HTTP {code}): {body}","messagePattern":"Unexpected response from deSEC during domain registration \\(HTTP (.+?)\\): (.+?)","errorType":"exception","errorClass":"\\Exception","httpStatus":422,"severity":"error","filePath":"php/src/Desec/DesecManager.php","lineNumber":328,"sourceCode":"                if ($this->ownsDomain($token, $domain)) {\n                    return $domain;\n                }\n                if ($code === 403) {\n                    throw new \\Exception(\n                        'Your deSEC account has reached its domain limit and \"' . $domain . '\" is not '\n                        . 'one of your existing domains. Remove an unused domain at desec.io, or contact '\n                        . 'deSEC support to raise the limit, then try again.'\n                    );\n                }\n                throw new \\Exception('\"' . $domain . '\" is already taken. Please choose a different subdomain and try again.');\n            }\n\n            if ($code === 409) {\n                // Random slug collided with an existing name — try another.\n                continue;\n            }\n\n            throw new \\Exception('Unexpected response from deSEC during domain registration (HTTP ' . $code . '): ' . $res->getBody()->getContents());\n        }\n\n        throw new \\Exception('Could not register a free dedyn.io domain after ' . self::MAX_SLUG_ATTEMPTS . ' attempts. Please try again.');\n    }\n\n    /**\n     * Checks whether the authenticated account already owns the given domain.\n     *\n     * Used to recover from a failed creation when the user is reusing a slug they\n     * registered earlier: GET /domains/{name}/ returns 200 only for a domain the\n     * token's account owns, 404 otherwise.\n     *\n     * @throws \\Exception on network failure or an unexpected HTTP response\n     */\n    private function ownsDomain(string $token, string $domain): bool {\n        try {\n            $res = $this->guzzleClient->get($this->configurationManager->desecApiBase . '/domains/' . $domain . '/', [\n                'headers' => ['Authorization' => 'Token ' . $token],","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/nextcloud/all-in-one/blob/6b788eec5e61733cf03ed380a3572e43ae3f11ce/php/src/Desec/DesecManager.php#L310-L346","documentation":"POST /domains/ returned a status outside every handled case — not 201 (created), and for user slugs not 400/403/409 either; for random slugs any non-201/non-409 code (including 400/403) lands here immediately. The raw body is embedded.","triggerScenarios":"429 domain-creation rate limit; 401 token expired/revoked between login and creation; 5xx from deSEC; random-slug mode receiving 403 (quota) or 400, which have no continue-path and throw here.","commonSituations":"deSEC incident returning 502/503; long gap between login and domain creation invalidating the token; rate limiting after repeated setup attempts.","solutions":["Read the embedded body for the API's own explanation","On 401, re-login to obtain a fresh token and retry creation","On 429, wait and retry later rather than immediately re-running","On 5xx, check deSEC status and retry after recovery"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    $domain = $manager->registerDomain($token, $slug);\n} catch (\\Exception $e) {\n    if (preg_match('/during domain registration \\(HTTP (\\d+)\\)/', $e->getMessage(), $m)) {\n        if ($m[1] === '401') { $token = refreshDesecToken($email, $password); return retry(); }\n        if ($m[1] === '429') { scheduleRetry(60); return; }\n    }\n    throw $e;\n}","preventionTips":["Keep the token fresh — minimize delay between login and domain creation","Handle 401 by re-authenticating instead of reusing the dead token","Log the embedded body; it distinguishes API incidents from client mistakes"],"tags":["php","desec","http-status","domains"],"backgroundTag":"unexpected-http-status","analyzedSha":"6b788eec5e61733cf03ed380a3572e43ae3f11ce","analyzedAt":"2026-08-21T05:47:24.382Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}