mirror of
https://github.com/twentyhq/twenty
synced 2026-04-21 13:37:22 +00:00
Fix CalDAV connection test reporting all errors as invalid credentials
https://sonarly.com/issue/29316?type=bug CalDAV connection testing catches all errors (discovery failures, missing homeUrl, no VEVENT calendars) and reports them as "Invalid CALDAV credentials," blocking users of standard-compliant self-hosted CalDAV servers from connecting despite valid credentials. Fix: Changed the CalDAV connection test error handler in `testCaldavConnection()` to properly classify errors instead of mapping all non-socket/non-sync errors to "invalid credentials": 1. **Added `"Invalid credentials"` check** (line 168-172): Only tsdav's actual 401-based auth error now shows the "invalid credentials" user message. This is the exact string tsdav throws when the server returns HTTP 401. 2. **Added CalDAV discovery error check** (lines 174-182): Discovery failures (`"cannot find homeUrl"`, `"cannot find calendarUserAddresses"`, `"No calendar with event support found"`) now get an accurate message: "We couldn't discover calendars on your CalDAV server. Please verify your server URL is correct and that your server supports CalDAV calendar discovery." These are the errors self-hosted servers (Baikal, Radicale) trigger when tsdav's PROPFIND-based discovery can't parse their responses. 3. **Changed the catch-all fallback** (lines 184-186): Unknown errors now get a generic "We encountered an issue connecting to your CalDAV server" message (matching the IMAP handler pattern) instead of blaming credentials. The error message strings come from the team's own `parse-caldav-error.util.ts` which already catalogs known tsdav errors.
This commit is contained in:
parent
071980d511
commit
f6d0219838
1 changed files with 35 additions and 5 deletions
|
|
@ -134,10 +134,24 @@ export class ImapSmtpCaldavService {
|
|||
await client.listCalendars();
|
||||
await client.validateSyncCollectionSupport();
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
`CALDAV connection failed: ${error.message}`,
|
||||
error.stack,
|
||||
);
|
||||
const isUserError =
|
||||
error.message?.includes('CALDAV_SYNC_COLLECTION_NOT_SUPPORTED') ||
|
||||
error.message === 'Invalid credentials' ||
|
||||
error.message === 'cannot find homeUrl' ||
|
||||
error.message === 'cannot find calendarUserAddresses' ||
|
||||
error.message === 'No calendar with event support found' ||
|
||||
error.code === 'FailedToOpenSocket';
|
||||
|
||||
if (isUserError) {
|
||||
this.logger.warn(
|
||||
`CALDAV connection test failed (user/server issue): ${error.message}`,
|
||||
);
|
||||
} else {
|
||||
this.logger.error(
|
||||
`CALDAV connection failed: ${error.message}`,
|
||||
error.stack,
|
||||
);
|
||||
}
|
||||
|
||||
if (error.message?.includes('CALDAV_SYNC_COLLECTION_NOT_SUPPORTED')) {
|
||||
throw new UserInputError(`CALDAV connection failed: ${error.message}`, {
|
||||
|
|
@ -151,8 +165,24 @@ export class ImapSmtpCaldavService {
|
|||
});
|
||||
}
|
||||
|
||||
if (error.message === 'Invalid credentials') {
|
||||
throw new UserInputError(`CALDAV connection failed: ${error.message}`, {
|
||||
userFriendlyMessage: msg`Invalid CALDAV credentials. Please check your username and password.`,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
error.message === 'cannot find homeUrl' ||
|
||||
error.message === 'cannot find calendarUserAddresses' ||
|
||||
error.message === 'No calendar with event support found'
|
||||
) {
|
||||
throw new UserInputError(`CALDAV connection failed: ${error.message}`, {
|
||||
userFriendlyMessage: msg`We couldn't discover calendars on your CalDAV server. Please verify your server URL is correct and that your server supports CalDAV calendar discovery.`,
|
||||
});
|
||||
}
|
||||
|
||||
throw new UserInputError(`CALDAV connection failed: ${error.message}`, {
|
||||
userFriendlyMessage: msg`Invalid CALDAV credentials. Please check your username and password.`,
|
||||
userFriendlyMessage: msg`We encountered an issue connecting to your CalDAV server. Please check your settings and try again.`,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue