{"record":{"id":"f22cb90b993983c8","repo":"nextcloud/all-in-one","slug":"a-domain-is-already-configured-reset-the-aio-inst","errorCode":null,"errorMessage":"A domain is already configured. Reset the AIO instance first to register a new domain.","messagePattern":"A domain is already configured\\. Reset the AIO instance first to register a new domain\\.","errorType":"exception","errorClass":"\\Exception","httpStatus":422,"severity":"error","filePath":"php/src/Desec/DesecManager.php","lineNumber":43,"sourceCode":"    }\n\n    /**\n     * Full registration flow: validates inputs, creates an account if needed,\n     * registers the domain, enables required containers, and updates the DNS record.\n     *\n     * When $password is non-empty the user is logging into an existing deSEC account\n     * rather than creating a new one. When $password is empty a new account is created\n     * with a randomly generated password (unless an account was already registered in a\n     * previous attempt).\n     *\n     * @return bool true when the domain was fully registered; false when a new account was\n     *         just created and we are now awaiting the user's email verification (a normal,\n     *         non-error outcome — the awaiting-verification UI explains the next step).\n     * @throws \\Exception on any validation or API error\n     */\n    public function register(string $email, string $slug, string $password = ''): bool {\n        if ($this->configurationManager->domain !== '') {\n            throw new \\Exception('A domain is already configured. Reset the AIO instance first to register a new domain.');\n        }\n\n        $validatedSlug = $this->validateSlug($slug);\n\n        // Persist the requested slug so the form can pre-fill it when it re-renders on the\n        // next step of the flow (e.g. after email verification). Cleared once a domain is set.\n        $this->configurationManager->desecSlug = $validatedSlug;\n\n        [$token, $isNewAccount] = $this->obtainToken($email, $password);\n\n        // An empty token means a brand-new account was created but its email is not yet\n        // verified. That is not an error: the account state is already persisted, so report\n        // \"awaiting verification\" to the caller and let it re-render the awaiting UI.\n        if ($token === '') {\n            return false;\n        }\n\n        $domain = $this->registerDomain($token, $validatedSlug);","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/nextcloud/all-in-one/blob/6b788eec5e61733cf03ed380a3572e43ae3f11ce/php/src/Desec/DesecManager.php#L25-L61","documentation":"Thrown by DesecManager::register when the ConfigurationManager already has a non-empty domain configured. The deSEC registration flow (domain obtainment via the AIO interface) is one-shot per instance: once a domain is stored, re-running register would create a second account/domain, so it refuses and asks for an instance reset first.","triggerScenarios":"Calling register() (via the AIO web UI domain/deSEC flow or directly) after a domain was already successfully set, including when the user re-submits the deSEC form after a partially completed earlier attempt that already stored the domain.","commonSituations":"Double-submitting the deSEC registration form; browser back/refresh resubmitting POST; retrying an automation script after it actually succeeded; a prior attempt that completed domain setup but showed an error to the user.","solutions":["Check the current domain first (configurationManager->domain) and skip registration when it is set.","If you genuinely need a new domain, reset the AIO instance first (which clears the stored domain), understanding that a reset has wider effects.","For automation, make the register call idempotent by guarding on the existing domain state."],"exampleFix":"// before\n$desecManager->register($email, $slug, $password);\n\n// after\nif ($configurationManager->domain === '') {\n    $desecManager->register($email, $slug, $password);\n}","handlingStrategy":"validation","validationCode":"if ($configurationManager->domain !== '') {\n    // skip register(); domain already set\n}","typeGuard":null,"tryCatchPattern":"try {\n    $desecManager->register($email, $slug, $password);\n} catch (\\Exception $e) {\n    if (str_contains($e->getMessage(), 'A domain is already configured')) {\n        // not an error: proceed with existing domain\n    }\n}","preventionTips":["Disable the submit button after success to prevent double POSTs.","In scripts, query the configured domain before attempting registration."],"tags":["php","nextcloud-aio","desec","dns","state-conflict","registration"],"backgroundTag":"resource-already-exists","analyzedSha":"6b788eec5e61733cf03ed380a3572e43ae3f11ce","analyzedAt":"2026-08-21T05:47:24.382Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}