Skip to content

Zod error in parse request after hapi-sentry upgrade #148

@gugu

Description

@gugu

Stack trace:

ZodError: [
  {
    "code": "invalid_arguments",
    "argumentsError": {
      "issues": [
        {
          "code": "invalid_type",
          "expected": "function",
          "received": "object",
          "path": [
            0
          ],
          "m...
  File "/app/node_modules/zod/lib/types.js", line 2721, in Object.parseRequest
    throw new ZodError_1.ZodError([makeArgsIssue(args, parsedArgs.error)]);
  File "/app/node_modules/hapi-sentry/index.js", line 73, in <anonymous>
    const sentryEvent = Sentry.Handlers.parseRequest(_sentryEvent, request.raw.req);
  File "/app/node_modules/@sentry/src/eventProcessors.ts", line 37, in <anonymous>
  File "/app/node_modules/@sentry/src/syncpromise.ts", line 61, in SyncPromise
  File "/app/node_modules/@sentry/src/eventProcessors.ts", line 32, in notifyEventProcessors
...
(5 additional frame(s) were not displayed)

Related piece of code:


    Sentry.withScope(scope => { // thus use a temp scope and re-assign it
      scope.addEventProcessor(_sentryEvent => {
        // format a sentry event from the request and triggered event
        const sentryEvent = Sentry.Handlers.parseRequest(_sentryEvent, request.raw.req); // <-- here
        // overwrite events request url if a baseUrl is provided
        if (opts.baseUri) {
          if (opts.baseUri.slice(-1) === '/') opts.baseUri = opts.baseUri.slice(0, -1);
          sentryEvent.request.url = opts.baseUri + request.path;
        }

Related versions in package.json:

{
  "name": "stator-query",
  "version": "1.0.1",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "@hapi/catbox": "^12.1.1",
    "@hapi/catbox-memcached": "^4.0.0",
    "@hapi/hapi": "^21.3.3",
    "@hapi/inert": "^7.1.0",
    "@hapi/vision": "^7.0.3",
    "hapi-auth-jwt2": "^10.5.1",
    "hapi-pino": "^12.1.0",
    "hapi-rate-limit": "^7.1.0",
    "hapi-sentry": "4.0.1-2",
    "hapi-swagger": "^17.2.1",
    ...
  },
  "type": "module",
}

Transitive:
zod@3.22.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions