Sonarly Claude Code 8822ffb305 fix(auth): handle Google Calendar 403 "not signed up" error as unavailable service
https://sonarly.com/issue/33071?type=bug

`checkCalendarAvailability` only catches `failedPrecondition` (HTTP 400) errors but Google also returns HTTP 403 with "The user must be signed up for Google Calendar." for accounts without Calendar provisioned. This unhandled 403 bubbles up as an uncaught error to Sentry and shows a confusing error redirect to the user.

Fix: Extended `isServiceNotEnabledError()` in `GoogleApisServiceAvailabilityService` to handle HTTP 403 errors where Google returns "The user must be signed up for Google Calendar." (or similar "must be signed up" messages for any Google service).

**What changed:**

1. **`google-apis-service-availability.service.ts`**: The `isServiceNotEnabledError` method now also checks for HTTP 403 responses with error messages containing "must be signed up". Previously it only handled HTTP 400 `failedPrecondition` errors. The fix:
   - Extracts the HTTP status code from `error.response.status` (previously only `error.response.data.error` was used)
   - After checking the existing `failedPrecondition` conditions, adds a second check: if the response status is 403 AND the error message contains "must be signed up", the error is classified as service-not-enabled
   - Renamed `gmailError` → `googleError` since this method handles both Gmail and Calendar errors

2. **`google-apis-service-availability.service.spec.ts`**: Added a test case that simulates the exact error from the Sentry event — a 403 response with `reason: 'notACalendarUser'` and message "The user must be signed up for Google Calendar." — and verifies that `checkServicesAvailability` returns `isCalendarAvailable: false` instead of throwing.

**Why this approach:**
- Follows the same pattern as the previous fix (commit e7f958c9cf) which extended the error classifier
- The condition `isForbidden && isNotSignedUp` is specific enough to avoid false positives (requires both 403 status AND "must be signed up" in the message)
- The fix handles the error at the right layer — the availability check returns `false`, allowing the OAuth flow to continue with Gmail-only integration (or show a proper error if neither service is available)

**Monitoring impact:**
By catching this error in `isServiceNotEnabledError`, it no longer propagates as a raw GaxiosError to the controller's catch block, which means `GuardRedirectService.captureException()` is never called for this error. This eliminates the Sentry noise without any separate monitoring code changes.
2026-04-30 16:20:42 +00:00
2025-08-07 17:02:12 +02:00

Twenty logo

The #1 Open-Source CRM

Website · Documentation · Roadmap · Discord · Figma

Twenty banner


Why Twenty

Twenty gives technical teams the building blocks for a custom CRM that meets complex business needs and quickly adapts as the business evolves. Twenty is the CRM you build, ship, and version like the rest of your stack.

Learn more about why we built Twenty


Installation

Cloud

The fastest way to get started. Sign up at twenty.com and spin up a workspace in under a minute, with no infrastructure to manage and always up to date.

Build an app

Scaffold a new app with the Twenty CLI:

npx create-twenty-app my-app

Define objects, fields, and views as code:

import { defineObject, FieldType } from 'twenty-sdk/define';

export default defineObject({
  nameSingular: 'deal',
  namePlural: 'deals',
  labelSingular: 'Deal',
  labelPlural: 'Deals',
  fields: [
    { name: 'name', label: 'Name', type: FieldType.TEXT },
    { name: 'amount', label: 'Amount', type: FieldType.CURRENCY },
    { name: 'closeDate', label: 'Close Date', type: FieldType.DATE_TIME },
  ],
});

Then ship it to your workspace:

npx twenty deploy

See the app development guide for objects, views, agents, and logic functions.

Self-hosting

Run Twenty on your own infrastructure with Docker Compose, or contribute locally via the local setup guide.



Everything you need

Twenty gives you the building blocks of a modern CRM (objects, views, workflows, and agents) and lets you extend them as code. Here's a tour of what's in the box.

Want to go deeper? Read the User Guide for product walkthroughs, or the Documentation for developer reference.

Create your apps

Learn more about apps in doc

Stay on top with version control

Learn more about version control in doc

All the tools you need to build anything

Learn more about primitives in doc

Customize your layouts

Learn more about layouts in doc

AI agents and chats

Learn more about AI in doc

Plus all the tools of a good CRM

Learn more about CRM features in doc


Stack

Thanks

Chromatic      Greptile      Sentry      Crowdin

Thanks to these amazing services that we use and recommend for UI testing (Chromatic), code review (Greptile), catching bugs (Sentry) and translating (Crowdin).

Join the Community

Star the repo · Discord · Feature requests · Releases · X · LinkedIn · Crowdin · Contribute

Languages
TypeScript 78%
MDX 18.5%
JavaScript 3.1%
Python 0.2%