Skip to content

DNS verification swallows resolver errors silently — no logging, no error class differentiation #88

@dobby-coder

Description

@dobby-coder

Problem

`src/lib/server/services/dns-verification.ts:65-71` catches every error from `resolve(record.domain, 'TXT')` and returns the same generic message. Nothing is logged, so debugging a failed DNS verification is impossible from server logs.

```ts
} catch {
await db
.update(dnsVerifications)
.set({ lastCheckedAt: new Date() })
.where(eq(dnsVerifications.id, record.id));
return { verified: false, error: `Could not resolve DNS for ${record.domain}` };
}
```

Affected debugging cases:

  • `ENOTFOUND` (domain doesn't exist) vs `ENODATA` (no TXT records) vs network failure are indistinguishable.
  • Users see the same opaque "Could not resolve DNS" error for every cause.
  • Operators have no log line to grep when a customer reports "my DNS check keeps failing".

Suggested fix

```ts
} catch (err) {
console.error('[dns-verification] resolve failed', {
orgId,
domain: record.domain,
code: (err as NodeJS.ErrnoException)?.code,
message: err instanceof Error ? err.message : String(err)
});
await db
.update(dnsVerifications)
.set({ lastCheckedAt: new Date() })
.where(eq(dnsVerifications.id, record.id));
const code = (err as NodeJS.ErrnoException)?.code;
const userMsg =
code === 'ENOTFOUND' ? `Domain ${record.domain} not found` :
code === 'ENODATA' ? `No TXT records found for ${record.domain}` :
`Could not resolve DNS for ${record.domain}`;
return { verified: false, error: userMsg };
}
```

Test plan

  • Existing happy-path test still passes.
  • New test: mocked `resolve()` throwing `ENOTFOUND` → returned error string contains "not found".
  • New test: mocked `resolve()` throwing generic Error → fallback message returned, `console.error` was called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions