From 4db0afa762c3417eea233459104986efc4b62a2c Mon Sep 17 00:00:00 2001
From: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Date: Mon, 26 Jan 2026 15:26:38 +0530
Subject: [PATCH] Upgrade fastify dependency

---
 package.json   |  3 ++-
 pnpm-lock.yaml | 54 +++++++++++++++++++++++++++-----------------------
 src/index.ts   | 19 ++++++++++--------
 3 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/package.json b/package.json
index 7cc444f..fad9c66 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
   "dependencies": {
     "@automa/bot": "~0.3.0",
     "@fastify/autoload": "~6.3.1",
+    "@fastify/error": "~4.2.0",
     "@fastify/helmet": "~13.0.2",
     "@fastify/sensible": "~6.0.3",
     "@fastify/swagger": "~9.5.2",
@@ -19,7 +20,7 @@
     "@opentelemetry/semantic-conventions": "~1.26.0",
     "@segment/analytics-node": "~1.1.0",
     "@sentry/node": "~7.59.3",
-    "fastify": "~5.6.1",
+    "fastify": "~5.6.2",
     "fastify-plugin": "~5.1.0",
     "http-errors": "~2.0.0",
     "nested-env-schema": "~1.3.1",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6da6374..6fa110e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -14,6 +14,9 @@ importers:
       '@fastify/autoload':
         specifier: ~6.3.1
         version: 6.3.1
+      '@fastify/error':
+        specifier: ~4.2.0
+        version: 4.2.0
       '@fastify/helmet':
         specifier: ~13.0.2
         version: 13.0.2
@@ -54,8 +57,8 @@ importers:
         specifier: ~7.59.3
         version: 7.59.3
       fastify:
-        specifier: ~5.6.1
-        version: 5.6.1
+        specifier: ~5.6.2
+        version: 5.6.2
       fastify-plugin:
         specifier: ~5.1.0
         version: 5.1.0
@@ -625,6 +628,9 @@ packages:
     resolution: {integrity: sha512-sAay1RrB+ONOem0OZanAR1ZI/k7yDpnOQSQmTMuGImUQb2y8EbSaCJ94FQluM74xoU03vlb2d2U90hZluL6nQg==}
     engines: {node: '>=14'}
 
+  '@pinojs/redact@0.4.0':
+    resolution: {integrity: sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==}
+
   '@pkgjs/parseargs@0.11.0':
     resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
     engines: {node: '>=14'}
@@ -1621,8 +1627,8 @@ packages:
   fastify-plugin@5.1.0:
     resolution: {integrity: sha512-FAIDA8eovSt5qcDgcBvDuX/v0Cjz0ohGhENZ/wpc3y+oZCY2afZ9Baqql3g/lC+OHRnciQol4ww7tuthOb9idw==}
 
-  fastify@5.6.1:
-    resolution: {integrity: sha512-WjjlOciBF0K8pDUPZoGPhqhKrQJ02I8DKaDIfO51EL0kbSMwQFl85cRwhOvmSDWoukNOdTo27gLN549pLCcH7Q==}
+  fastify@5.6.2:
+    resolution: {integrity: sha512-dPugdGnsvYkBlENLhCgX8yhyGCsCPrpA8lFWbTNU428l+YOnLgYHR69hzV8HWPC79n536EqzqQtvhtdaCE0dKg==}
 
   fastq@1.17.1:
     resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==}
@@ -2597,14 +2603,14 @@ packages:
     resolution: {integrity: sha512-g0VU+y08pKw5M8EZ2rIGiEBaB8wrQMjYGFfW2QVIfyT8V+fq8YFLkvlz4bz5ljvFDJYNFCWT3PWqcRr2FKO81w==}
     engines: {node: '>=10'}
 
-  pino-abstract-transport@2.0.0:
-    resolution: {integrity: sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==}
+  pino-abstract-transport@3.0.0:
+    resolution: {integrity: sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==}
 
   pino-std-serializers@7.0.0:
     resolution: {integrity: sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==}
 
-  pino@9.13.1:
-    resolution: {integrity: sha512-Szuj+ViDTjKPQYiKumGmEn3frdl+ZPSdosHyt9SnUevFosOkMY2b7ipxlEctNKPmMD/VibeBI+ZcZCJK+4DPuw==}
+  pino@10.3.0:
+    resolution: {integrity: sha512-0GNPNzHXBKw6U/InGe79A3Crzyk9bcSyObF9/Gfo9DLEf5qj5RF50RSjsu0W1rZ6ZqRGdzDFCRBQvi9/rSGPtA==}
     hasBin: true
 
   pkg-dir@4.2.0:
@@ -2874,9 +2880,6 @@ packages:
     resolution: {integrity: sha512-bSiSngZ/jWeX93BqeIAbImyTbEihizcwNjFoRUIY/T1wWQsfsm2Vw1agPKylXvQTU7iASGdHhyqRlqQzfz+Htg==}
     engines: {node: '>=18'}
 
-  slow-redact@0.3.1:
-    resolution: {integrity: sha512-NvFvl1GuLZNW4U046Tfi8b26zXo8aBzgCAS2f7yVJR/fArN93mOqSA99cB9uITm92ajSz01bsu1K7SCVVjIMpQ==}
-
   smart-buffer@4.2.0:
     resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==}
     engines: {node: '>= 6.0.0', npm: '>= 3.0.0'}
@@ -3015,8 +3018,9 @@ packages:
   text-table@0.2.0:
     resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}
 
-  thread-stream@3.1.0:
-    resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==}
+  thread-stream@4.0.0:
+    resolution: {integrity: sha512-4iMVL6HAINXWf1ZKZjIPcz5wYaOdPhtO8ATvZ+Xqp3BTdaqtAwQkNmKORqcIo5YkQqGXq5cwfswDwMqqQNrpJA==}
+    engines: {node: '>=20'}
 
   tinyexec@0.2.0:
     resolution: {integrity: sha512-au8dwv4xKSDR+Fw52csDo3wcDztPdne2oM1o/7LFro4h6bdFmvyUAeAfX40pwDtzHgRFqz1XWaUqgKS2G83/ig==}
@@ -3499,7 +3503,7 @@ snapshots:
     dependencies:
       ajv: 8.17.1
       ajv-formats: 3.0.1(ajv@8.17.1)
-      fast-uri: 3.0.1
+      fast-uri: 3.1.0
 
   '@fastify/autoload@6.3.1': {}
 
@@ -3959,6 +3963,8 @@ snapshots:
 
   '@opentelemetry/semantic-conventions@1.27.0': {}
 
+  '@pinojs/redact@0.4.0': {}
+
   '@pkgjs/parseargs@0.11.0':
     optional: true
 
@@ -5108,7 +5114,7 @@ snapshots:
       '@fastify/merge-json-schemas': 0.2.1
       ajv: 8.17.1
       ajv-formats: 3.0.1(ajv@8.17.1)
-      fast-uri: 3.0.1
+      fast-uri: 3.1.0
       json-schema-ref-resolver: 3.0.0
       rfdc: 1.4.1
 
@@ -5124,7 +5130,7 @@ snapshots:
 
   fastify-plugin@5.1.0: {}
 
-  fastify@5.6.1:
+  fastify@5.6.2:
     dependencies:
       '@fastify/ajv-compiler': 4.0.2
       '@fastify/error': 4.2.0
@@ -5135,7 +5141,7 @@ snapshots:
       fast-json-stringify: 6.1.1
       find-my-way: 9.3.0
       light-my-request: 6.6.0
-      pino: 9.13.1
+      pino: 10.3.0
       process-warning: 5.0.0
       rfdc: 1.4.1
       secure-json-parse: 4.0.0
@@ -6151,25 +6157,25 @@ snapshots:
     dependencies:
       safe-buffer: 5.2.1
 
-  pino-abstract-transport@2.0.0:
+  pino-abstract-transport@3.0.0:
     dependencies:
       split2: 4.2.0
 
   pino-std-serializers@7.0.0: {}
 
-  pino@9.13.1:
+  pino@10.3.0:
     dependencies:
+      '@pinojs/redact': 0.4.0
       atomic-sleep: 1.0.0
       on-exit-leak-free: 2.1.2
-      pino-abstract-transport: 2.0.0
+      pino-abstract-transport: 3.0.0
       pino-std-serializers: 7.0.0
       process-warning: 5.0.0
       quick-format-unescaped: 4.0.4
       real-require: 0.2.0
       safe-stable-stringify: 2.4.3
-      slow-redact: 0.3.1
       sonic-boom: 4.2.0
-      thread-stream: 3.1.0
+      thread-stream: 4.0.0
 
   pkg-dir@4.2.0:
     dependencies:
@@ -6493,8 +6499,6 @@ snapshots:
       ansi-styles: 6.2.1
       is-fullwidth-code-point: 5.0.0
 
-  slow-redact@0.3.1: {}
-
   smart-buffer@4.2.0: {}
 
   socks-proxy-agent@8.0.4:
@@ -6638,7 +6642,7 @@ snapshots:
 
   text-table@0.2.0: {}
 
-  thread-stream@3.1.0:
+  thread-stream@4.0.0:
     dependencies:
       real-require: 0.2.0
 
diff --git a/src/index.ts b/src/index.ts
index 1251a0e..0258b9c 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -5,6 +5,7 @@ import { env, isProduction, isTest, version } from './env';
 
 import fastify from 'fastify';
 import fastifyAutoload from '@fastify/autoload';
+import { FastifyError } from '@fastify/error';
 import fastifyHelmet from '@fastify/helmet';
 import fastifySensible from '@fastify/sensible';
 import fastifySwagger from '@fastify/swagger';
@@ -37,14 +38,16 @@ export const server = async () => {
       return error;
     }
 
-    if (error.code === 'FST_ERR_VALIDATION') {
-      return reply.unprocessableEntity(error.message);
-    } else if (error.code === 'FST_ERR_CTP_BODY_TOO_LARGE') {
-      return reply.payloadTooLarge(error.message);
-    } else if (error.code === 'FST_ERR_CTP_INVALID_MEDIA_TYPE') {
-      return reply.unsupportedMediaType(error.message);
-    } else if (error.statusCode === 400) {
-      return reply.badRequest(error.message);
+    if (error instanceof FastifyError) {
+      if (error.code === 'FST_ERR_VALIDATION') {
+        return reply.unprocessableEntity(error.message);
+      } else if (error.code === 'FST_ERR_CTP_BODY_TOO_LARGE') {
+        return reply.payloadTooLarge(error.message);
+      } else if (error.code === 'FST_ERR_CTP_INVALID_MEDIA_TYPE') {
+        return reply.unsupportedMediaType(error.message);
+      } else if (error.statusCode === 400) {
+        return reply.badRequest(error.message);
+      }
     }
 
     app.error.capture(error, { method: request.method, url: request.url });
