Repository navigation
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/google-cloud-serverless
SDK Version
9.30.0
Framework Version
@sentry/google-cloud-serverless@9.30.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
import * as Sentry from "@sentry/google-cloud-serverless";
import { type CloudEvent } from "@google-cloud/functions-framework";
Sentry.wrapCloudEventFunction(async (cloudevent: CloudEvent<any>) => {});Steps to Reproduce
- Install
@google-cloud/functions-framework@4.0.0,typescript@5.8.3and@sentry/google-cloud-serverless@9.30.0 - Paste repro script
- Run
tsc --noEmit, strict mode enabled
Worth noting here is that functions-framework@4.0.0 installs "cloudevents": "^8.0.2"
Expected Result
No typechecking errors
Actual Result
> tsc --noEmit
index.ts:30:31 - error TS2345: Argument of type '(cloudevent: CloudEvent<any>) => Promise<void>' is not assignable to parameter of type 'CloudEventFunction | CloudEventFunctionWithCallback'.
Type '(cloudevent: CloudEvent<any>) => Promise<void>' is not assignable to type 'CloudEventFunction'.
Types of parameters 'cloudevent' and 'cloudevent' are incompatible.
Type 'CloudEventsContext' is not assignable to type 'CloudEventV1<any>'.
Types of property 'id' are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
30 Sentry.wrapCloudEventFunction(async (cloudevent: CloudEvent<any>) => {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To rephrase the error message; problem is that attributes of the CloudEventsContext interface from Sentry are not matching with the CloudEvent interface from Google's functions framework package, where CloudEvent is reexported from cloudevents.
CloudEventsContext from Sentry:
sentry-javascript/packages/google-cloud-serverless/src/gcpfunction/general.ts
Lines 30 to 39 in b94f652
| export interface CloudEventsContext { | |
| [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any | |
| type?: string; | |
| specversion?: string; | |
| source?: string; | |
| id?: string; | |
| time?: string; | |
| schemaurl?: string; | |
| contenttype?: string; | |
| } |
vs. CloudEvent from functions framework (via cloudevents) (ref: https://github.com/cloudevents/sdk-javascript/blob/c07afa9b774deefa137a960d2d11adee0bf3674a/src/event/interfaces.ts#L10-L31):
export interface CloudEventV1<T> extends CloudEventV1Attributes<T> {
// REQUIRED Attributes
/**
* [REQUIRED] Identifies the event. Producers MUST ensure that `source` + `id`
* is unique for each distinct event. If a duplicate event is re-sent (e.g. due
* to a network error) it MAY have the same `id`. Consumers MAY assume that
* Events with identical `source` and `id` are duplicates.
* @required Non-empty string. Unique within producer.
* @example An event counter maintained by the producer
* @example A UUID
*/
id: string;
/**
* [REQUIRED] The version of the CloudEvents specification which the event
* uses. This enables the interpretation of the context. Compliant event
* producers MUST use a value of `1.0` when referring to this version of the
* specification.
* @required MUST be a non-empty string.
*/
specversion: string;
}Metadata
Metadata
Assignees
Projects
- StatusShow more project fieldsNo status
Activity
AbhiPrasad commentedon Jun 19, 2025
Hey @flaeppe - thanks for writing in! I'm taking a look.
AbhiPrasad commentedon Jun 19, 2025
Opened #16661 as a fix
fix(google-cloud-serverless): Make `CloudEvent` type compatible (#16661)
github-actions commentedon Jun 23, 2025
A PR closing this issue has just been released 🚀
This issue was referenced by PR #16661, which was included in the 9.31.0 release.
flaeppe commentedon Jun 23, 2025
@AbhiPrasad I tried out the newly released changes from #16661 in https://github.com/getsentry/sentry-javascript/releases/tag/9.31.0 but it errored out on 2 other properties. Namely
sourceandtypewhich would also need to be required in order to haveCloudEventsContextcompatible withCloudEvent.Ref: https://github.com/cloudevents/sdk-javascript/blob/c07afa9b774deefa137a960d2d11adee0bf3674a/src/event/interfaces.ts#L33-L66
When also making
sourceandtyperequired forCloudEventsContextI didn't see any more errors.fix(google-cloud-serverless): Make `CloudEventsContext` compatible wi…