Compare commits

...
Author SHA1 Message Date
Sonarly Claude Code 236901d12c refreshHostname throws generic "Value not defined" when custom domain missing from Cloudflare
https://sonarly.com/issue/6662?type=bug

When a user checks DNS records for their custom domain, the server crashes with a generic "Value not defined" error because the hostname doesn't exist in Cloudflare's custom hostnames, despite being set in the workspace database.

Fix: The fix replaces the bare `assertIsDefinedOrThrow(publicDomainWithRecords)` call in `refreshHostname()` with one that passes a proper `DnsManagerException` as the second argument.

Previously, when `getHostnameWithRecords()` returned `undefined` (because the hostname wasn't found in Cloudflare), the assertion threw the default `Error("Value not defined")`. Now it throws a `DnsManagerException` with:
- Code `HOSTNAME_NOT_REGISTERED` (already defined in the exception enum)
- A user-friendly message `"Domain is not registered in Cloudflare"`

This matches the existing pattern used throughout the same service (e.g., `HOSTNAME_ALREADY_REGISTERED` in `registerHostname()`) and uses the already-imported `msg`, `DnsManagerException`, and `DnsManagerExceptionCode` symbols — no new imports or files needed.

```typescript file=packages/twenty-server/src/engine/core-modules/dns-manager/services/dns-manager.service.ts lines=141-150
    assertIsDefinedOrThrow(
      publicDomainWithRecords,
      new DnsManagerException(
        'Hostname not found in Cloudflare',
        DnsManagerExceptionCode.HOSTNAME_NOT_REGISTERED,
        {
          userFriendlyMessage: msg`Domain is not registered in Cloudflare`,
        },
      ),
    );
```
2026-03-05 04:18:36 +00:00
@@ -138,7 +138,16 @@ export class DnsManagerService {
options,
);
assertIsDefinedOrThrow(publicDomainWithRecords);
assertIsDefinedOrThrow(
publicDomainWithRecords,
new DnsManagerException(
'Hostname not found in Cloudflare',
DnsManagerExceptionCode.HOSTNAME_NOT_REGISTERED,
{
userFriendlyMessage: msg`Domain is not registered in Cloudflare`,
},
),
);
await this.cloudflareClient.customHostnames.edit(
publicDomainWithRecords.id,