@mastra/hono 1.1.9 → 1.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @mastra/hono
2
2
 
3
+ ## 1.2.0-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`866cc2c`](https://github.com/mastra-ai/mastra/commit/866cc2cb1f0e3b314afab5194f69477fada745d1), [`6bcbf8a`](https://github.com/mastra-ai/mastra/commit/6bcbf8a6774d5a53b21d61db8a45ce2593ca1616), [`18c3a90`](https://github.com/mastra-ai/mastra/commit/18c3a90c9e48cf69500e308affeb8eba5860b2af), [`f35487b`](https://github.com/mastra-ai/mastra/commit/f35487bb2d46c636e22aa71d90025613ae38235a), [`6dc2192`](https://github.com/mastra-ai/mastra/commit/6dc21921aef0f0efab15cd0805fa3d18f277a76f), [`eeb3a3f`](https://github.com/mastra-ai/mastra/commit/eeb3a3f43aca10cf49479eed2a84b7d9ecea02ba), [`05f8d90`](https://github.com/mastra-ai/mastra/commit/05f8d9009290ce6aa03428b3add635268615db85), [`4b8da97`](https://github.com/mastra-ai/mastra/commit/4b8da97a5ce306e97869df6c39535d9069e563db), [`256df35`](https://github.com/mastra-ai/mastra/commit/256df3571d62beb3ad4971faa432927cc140e603)]:
8
+ - @mastra/core@1.11.0-alpha.1
9
+ - @mastra/server@1.11.0-alpha.1
10
+
11
+ ## 1.2.0-alpha.0
12
+
13
+ ### Minor Changes
14
+
15
+ - Added `onValidationError` hook to `ServerConfig` and `createRoute()`. When a request fails Zod schema validation (query parameters, request body, or path parameters), this hook lets you customize the error response — including the HTTP status code and response body — instead of the default 400 response. Set it on the server config to apply globally, or on individual routes to override per-route. All server adapters (Hono, Express, Fastify, Koa) support this hook. ([#13477](https://github.com/mastra-ai/mastra/pull/13477))
16
+
17
+ ```ts
18
+ const mastra = new Mastra({
19
+ server: {
20
+ onValidationError: (error, context) => ({
21
+ status: 422,
22
+ body: {
23
+ ok: false,
24
+ errors: error.issues.map(i => ({
25
+ path: i.path.join('.'),
26
+ message: i.message,
27
+ })),
28
+ source: context,
29
+ },
30
+ }),
31
+ },
32
+ });
33
+ ```
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [[`4f71b43`](https://github.com/mastra-ai/mastra/commit/4f71b436a4a6b8839842d8da47b57b84509af56c), [`a070277`](https://github.com/mastra-ai/mastra/commit/a07027766ce195ba74d0783116d894cbab25d44c), [`b628b91`](https://github.com/mastra-ai/mastra/commit/b628b9128b372c0f54214d902b07279f03443900), [`332c014`](https://github.com/mastra-ai/mastra/commit/332c014e076b81edf7fe45b58205882726415e90), [`6b63153`](https://github.com/mastra-ai/mastra/commit/6b63153878ea841c0f4ce632ba66bb33e57e9c1b), [`4246e34`](https://github.com/mastra-ai/mastra/commit/4246e34cec9c26636d0965942268e6d07c346671), [`b8837ee`](https://github.com/mastra-ai/mastra/commit/b8837ee77e2e84197609762bfabd8b3da326d30c), [`5d950f7`](https://github.com/mastra-ai/mastra/commit/5d950f7bf426a215a1808f0abef7de5c8336ba1c), [`28c85b1`](https://github.com/mastra-ai/mastra/commit/28c85b184fc32b40f7f160483c982da6d388ecbd), [`e9a08fb`](https://github.com/mastra-ai/mastra/commit/e9a08fbef1ada7e50e961e2f54f55e8c10b4a45c), [`631ffd8`](https://github.com/mastra-ai/mastra/commit/631ffd82fed108648b448b28e6a90e38c5f53bf5), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`aa61f29`](https://github.com/mastra-ai/mastra/commit/aa61f29ff8095ce46a4ae16e46c4d8c79b2b685b), [`7ff3714`](https://github.com/mastra-ai/mastra/commit/7ff37148515439bb3be009a60e02c3e363299760), [`41d79a1`](https://github.com/mastra-ai/mastra/commit/41d79a14bd8cb6de1e2565fd0a04786bae2f211b), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`e673376`](https://github.com/mastra-ai/mastra/commit/e6733763ad1321aa7e5ae15096b9c2104f93b1f3), [`b2204c9`](https://github.com/mastra-ai/mastra/commit/b2204c98a42848bbfb6f0440f005dc2b6354f1cd), [`a1bf1e3`](https://github.com/mastra-ai/mastra/commit/a1bf1e385ed4c0ef6f11b56c5887442970d127f2), [`b6f647a`](https://github.com/mastra-ai/mastra/commit/b6f647ae2388e091f366581595feb957e37d5b40), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`b081f27`](https://github.com/mastra-ai/mastra/commit/b081f272cf411716e1d6bd72ceac4bcee2657b19), [`0c09eac`](https://github.com/mastra-ai/mastra/commit/0c09eacb1926f64cfdc9ae5c6d63385cf8c9f72c), [`6b9b93d`](https://github.com/mastra-ai/mastra/commit/6b9b93d6f459d1ba6e36f163abf62a085ddb3d64), [`31b6067`](https://github.com/mastra-ai/mastra/commit/31b6067d0cc3ab10e1b29c36147f3b5266bc714a), [`797ac42`](https://github.com/mastra-ai/mastra/commit/797ac4276de231ad2d694d9aeca75980f6cd0419), [`0bc289e`](https://github.com/mastra-ai/mastra/commit/0bc289e2d476bf46c5b91c21969e8d0c6864691c), [`9b75a06`](https://github.com/mastra-ai/mastra/commit/9b75a06e53ebb0b950ba7c1e83a0142047185f46), [`4c3a1b1`](https://github.com/mastra-ai/mastra/commit/4c3a1b122ea083e003d71092f30f3b31680b01c0), [`85cc3b3`](https://github.com/mastra-ai/mastra/commit/85cc3b3b6f32ae4b083c26498f50d5b250ba944b), [`c2afbbc`](https://github.com/mastra-ai/mastra/commit/c2afbbccada13af07cad6742456f3f067ccd6519), [`97ea28c`](https://github.com/mastra-ai/mastra/commit/97ea28c746e9e4147d56047bbb1c4a92417a3fec), [`d567299`](https://github.com/mastra-ai/mastra/commit/d567299cf81e02bd9d5221d4bc05967d6c224161), [`716ffe6`](https://github.com/mastra-ai/mastra/commit/716ffe68bed81f7c2690bc8581b9e140f7bf1c3d), [`8296332`](https://github.com/mastra-ai/mastra/commit/8296332de21c16e3dfc3d0b2d615720a6dc88f2f), [`4df2116`](https://github.com/mastra-ai/mastra/commit/4df211619dd922c047d396ca41cd7027c8c4c8e7), [`2219c1a`](https://github.com/mastra-ai/mastra/commit/2219c1acbd21da116da877f0036ffb985a9dd5a3), [`17c4145`](https://github.com/mastra-ai/mastra/commit/17c4145166099354545582335b5252bdfdfd908b)]:
38
+ - @mastra/core@1.11.0-alpha.0
39
+ - @mastra/server@1.11.0-alpha.0
40
+
3
41
  ## 1.1.9
4
42
 
5
43
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var error = require('@mastra/server/handlers/error');
4
3
  var serverAdapter = require('@mastra/server/server-adapter');
5
4
  var fetchToNode = require('fetch-to-node');
6
5
 
@@ -175,11 +174,11 @@ var StreamingApi = class {
175
174
 
176
175
  // ../../node_modules/.pnpm/hono@4.11.9/node_modules/hono/dist/helper/streaming/utils.js
177
176
  var isOldBunVersion = () => {
178
- const version = typeof Bun !== "undefined" ? Bun.version : void 0;
179
- if (version === void 0) {
177
+ const version2 = typeof Bun !== "undefined" ? Bun.version : void 0;
178
+ if (version2 === void 0) {
180
179
  return false;
181
180
  }
182
- const result = version.startsWith("1.1") || version.startsWith("1.0") || version.startsWith("0.");
181
+ const result = version2.startsWith("1.1") || version2.startsWith("1.0") || version2.startsWith("0.");
183
182
  isOldBunVersion = () => result;
184
183
  return result;
185
184
  };
@@ -212,213 +211,214 @@ var stream = (c, cb, onError) => {
212
211
  })();
213
212
  return c.newResponse(stream2.responseReadable);
214
213
  };
215
-
216
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
217
- var util;
218
- (function(util2) {
219
- util2.assertEqual = (_) => {
220
- };
221
- function assertIs(_arg) {
222
- }
223
- util2.assertIs = assertIs;
224
- function assertNever(_x) {
225
- throw new Error();
226
- }
227
- util2.assertNever = assertNever;
228
- util2.arrayToEnum = (items) => {
229
- const obj = {};
230
- for (const item of items) {
231
- obj[item] = item;
214
+ // @__NO_SIDE_EFFECTS__
215
+ function $constructor(name, initializer3, params) {
216
+ function init(inst, def) {
217
+ if (!inst._zod) {
218
+ Object.defineProperty(inst, "_zod", {
219
+ value: {
220
+ def,
221
+ constr: _,
222
+ traits: /* @__PURE__ */ new Set()
223
+ },
224
+ enumerable: false
225
+ });
232
226
  }
233
- return obj;
234
- };
235
- util2.getValidEnumValues = (obj) => {
236
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
237
- const filtered = {};
238
- for (const k of validKeys) {
239
- filtered[k] = obj[k];
227
+ if (inst._zod.traits.has(name)) {
228
+ return;
240
229
  }
241
- return util2.objectValues(filtered);
242
- };
243
- util2.objectValues = (obj) => {
244
- return util2.objectKeys(obj).map(function(e) {
245
- return obj[e];
246
- });
247
- };
248
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
249
- const keys = [];
250
- for (const key in object) {
251
- if (Object.prototype.hasOwnProperty.call(object, key)) {
252
- keys.push(key);
230
+ inst._zod.traits.add(name);
231
+ initializer3(inst, def);
232
+ const proto = _.prototype;
233
+ const keys = Object.keys(proto);
234
+ for (let i = 0; i < keys.length; i++) {
235
+ const k = keys[i];
236
+ if (!(k in inst)) {
237
+ inst[k] = proto[k].bind(inst);
253
238
  }
254
239
  }
255
- return keys;
256
- };
257
- util2.find = (arr, checker) => {
258
- for (const item of arr) {
259
- if (checker(item))
260
- return item;
240
+ }
241
+ const Parent = params?.Parent ?? Object;
242
+ class Definition extends Parent {
243
+ }
244
+ Object.defineProperty(Definition, "name", { value: name });
245
+ function _(def) {
246
+ var _a2;
247
+ const inst = params?.Parent ? new Definition() : this;
248
+ init(inst, def);
249
+ (_a2 = inst._zod).deferred ?? (_a2.deferred = []);
250
+ for (const fn of inst._zod.deferred) {
251
+ fn();
261
252
  }
262
- return void 0;
263
- };
264
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
265
- function joinValues(array, separator = " | ") {
266
- return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
267
- }
268
- util2.joinValues = joinValues;
269
- util2.jsonStringifyReplacer = (_, value) => {
270
- if (typeof value === "bigint") {
271
- return value.toString();
253
+ return inst;
254
+ }
255
+ Object.defineProperty(_, "init", { value: init });
256
+ Object.defineProperty(_, Symbol.hasInstance, {
257
+ value: (inst) => {
258
+ if (params?.Parent && inst instanceof params.Parent)
259
+ return true;
260
+ return inst?._zod?.traits?.has(name);
272
261
  }
273
- return value;
274
- };
275
- })(util || (util = {}));
276
- var objectUtil;
277
- (function(objectUtil2) {
278
- objectUtil2.mergeShapes = (first, second) => {
279
- return {
280
- ...first,
281
- ...second
282
- // second overwrites first
283
- };
284
- };
285
- })(objectUtil || (objectUtil = {}));
286
- util.arrayToEnum([
287
- "string",
288
- "nan",
289
- "number",
290
- "integer",
291
- "float",
292
- "boolean",
293
- "date",
294
- "bigint",
295
- "symbol",
296
- "function",
297
- "undefined",
298
- "null",
299
- "array",
300
- "object",
301
- "unknown",
302
- "promise",
303
- "void",
304
- "never",
305
- "map",
306
- "set"
307
- ]);
262
+ });
263
+ Object.defineProperty(_, "name", { value: name });
264
+ return _;
265
+ }
308
266
 
309
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
310
- util.arrayToEnum([
311
- "invalid_type",
312
- "invalid_literal",
313
- "custom",
314
- "invalid_union",
315
- "invalid_union_discriminator",
316
- "invalid_enum_value",
317
- "unrecognized_keys",
318
- "invalid_arguments",
319
- "invalid_return_type",
320
- "invalid_date",
321
- "invalid_string",
322
- "too_small",
323
- "too_big",
324
- "invalid_intersection_types",
325
- "not_multiple_of",
326
- "not_finite"
327
- ]);
328
- var ZodError = class _ZodError extends Error {
329
- get errors() {
330
- return this.issues;
331
- }
332
- constructor(issues) {
333
- super();
334
- this.issues = [];
335
- this.addIssue = (sub) => {
336
- this.issues = [...this.issues, sub];
337
- };
338
- this.addIssues = (subs = []) => {
339
- this.issues = [...this.issues, ...subs];
340
- };
341
- const actualProto = new.target.prototype;
342
- if (Object.setPrototypeOf) {
343
- Object.setPrototypeOf(this, actualProto);
267
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
268
+ function jsonStringifyReplacer(_, value) {
269
+ if (typeof value === "bigint")
270
+ return value.toString();
271
+ return value;
272
+ }
273
+
274
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js
275
+ var initializer = (inst, def) => {
276
+ inst.name = "$ZodError";
277
+ Object.defineProperty(inst, "_zod", {
278
+ value: inst._zod,
279
+ enumerable: false
280
+ });
281
+ Object.defineProperty(inst, "issues", {
282
+ value: def,
283
+ enumerable: false
284
+ });
285
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
286
+ Object.defineProperty(inst, "toString", {
287
+ value: () => inst.message,
288
+ enumerable: false
289
+ });
290
+ };
291
+ var $ZodError = $constructor("$ZodError", initializer);
292
+ function flattenError(error, mapper = (issue2) => issue2.message) {
293
+ const fieldErrors = {};
294
+ const formErrors = [];
295
+ for (const sub of error.issues) {
296
+ if (sub.path.length > 0) {
297
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
298
+ fieldErrors[sub.path[0]].push(mapper(sub));
344
299
  } else {
345
- this.__proto__ = actualProto;
300
+ formErrors.push(mapper(sub));
346
301
  }
347
- this.name = "ZodError";
348
- this.issues = issues;
349
302
  }
350
- format(_mapper) {
351
- const mapper = _mapper || function(issue) {
352
- return issue.message;
353
- };
354
- const fieldErrors = { _errors: [] };
355
- const processError = (error) => {
356
- for (const issue of error.issues) {
357
- if (issue.code === "invalid_union") {
358
- issue.unionErrors.map(processError);
359
- } else if (issue.code === "invalid_return_type") {
360
- processError(issue.returnTypeError);
361
- } else if (issue.code === "invalid_arguments") {
362
- processError(issue.argumentsError);
363
- } else if (issue.path.length === 0) {
364
- fieldErrors._errors.push(mapper(issue));
365
- } else {
366
- let curr = fieldErrors;
367
- let i = 0;
368
- while (i < issue.path.length) {
369
- const el = issue.path[i];
370
- const terminal = i === issue.path.length - 1;
371
- if (!terminal) {
372
- curr[el] = curr[el] || { _errors: [] };
373
- } else {
374
- curr[el] = curr[el] || { _errors: [] };
375
- curr[el]._errors.push(mapper(issue));
376
- }
377
- curr = curr[el];
378
- i++;
303
+ return { formErrors, fieldErrors };
304
+ }
305
+ function formatError(error, mapper = (issue2) => issue2.message) {
306
+ const fieldErrors = { _errors: [] };
307
+ const processError = (error2) => {
308
+ for (const issue2 of error2.issues) {
309
+ if (issue2.code === "invalid_union" && issue2.errors.length) {
310
+ issue2.errors.map((issues) => processError({ issues }));
311
+ } else if (issue2.code === "invalid_key") {
312
+ processError({ issues: issue2.issues });
313
+ } else if (issue2.code === "invalid_element") {
314
+ processError({ issues: issue2.issues });
315
+ } else if (issue2.path.length === 0) {
316
+ fieldErrors._errors.push(mapper(issue2));
317
+ } else {
318
+ let curr = fieldErrors;
319
+ let i = 0;
320
+ while (i < issue2.path.length) {
321
+ const el = issue2.path[i];
322
+ const terminal = i === issue2.path.length - 1;
323
+ if (!terminal) {
324
+ curr[el] = curr[el] || { _errors: [] };
325
+ } else {
326
+ curr[el] = curr[el] || { _errors: [] };
327
+ curr[el]._errors.push(mapper(issue2));
379
328
  }
329
+ curr = curr[el];
330
+ i++;
380
331
  }
381
332
  }
382
- };
383
- processError(this);
384
- return fieldErrors;
385
- }
386
- static assert(value) {
387
- if (!(value instanceof _ZodError)) {
388
- throw new Error(`Not a ZodError: ${value}`);
389
333
  }
334
+ };
335
+ processError(error);
336
+ return fieldErrors;
337
+ }
338
+
339
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js
340
+ var _a;
341
+ var $ZodRegistry = class {
342
+ constructor() {
343
+ this._map = /* @__PURE__ */ new WeakMap();
344
+ this._idmap = /* @__PURE__ */ new Map();
345
+ }
346
+ add(schema, ..._meta) {
347
+ const meta = _meta[0];
348
+ this._map.set(schema, meta);
349
+ if (meta && typeof meta === "object" && "id" in meta) {
350
+ this._idmap.set(meta.id, schema);
351
+ }
352
+ return this;
390
353
  }
391
- toString() {
392
- return this.message;
393
- }
394
- get message() {
395
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
354
+ clear() {
355
+ this._map = /* @__PURE__ */ new WeakMap();
356
+ this._idmap = /* @__PURE__ */ new Map();
357
+ return this;
396
358
  }
397
- get isEmpty() {
398
- return this.issues.length === 0;
359
+ remove(schema) {
360
+ const meta = this._map.get(schema);
361
+ if (meta && typeof meta === "object" && "id" in meta) {
362
+ this._idmap.delete(meta.id);
363
+ }
364
+ this._map.delete(schema);
365
+ return this;
399
366
  }
400
- flatten(mapper = (issue) => issue.message) {
401
- const fieldErrors = {};
402
- const formErrors = [];
403
- for (const sub of this.issues) {
404
- if (sub.path.length > 0) {
405
- const firstEl = sub.path[0];
406
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
407
- fieldErrors[firstEl].push(mapper(sub));
408
- } else {
409
- formErrors.push(mapper(sub));
410
- }
367
+ get(schema) {
368
+ const p = schema._zod.parent;
369
+ if (p) {
370
+ const pm = { ...this.get(p) ?? {} };
371
+ delete pm.id;
372
+ const f = { ...pm, ...this._map.get(schema) };
373
+ return Object.keys(f).length ? f : void 0;
411
374
  }
412
- return { formErrors, fieldErrors };
375
+ return this._map.get(schema);
413
376
  }
414
- get formErrors() {
415
- return this.flatten();
377
+ has(schema) {
378
+ return this._map.has(schema);
416
379
  }
417
380
  };
418
- ZodError.create = (issues) => {
419
- const error = new ZodError(issues);
420
- return error;
381
+ function registry() {
382
+ return new $ZodRegistry();
383
+ }
384
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
385
+
386
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
387
+ var initializer2 = (inst, issues) => {
388
+ $ZodError.init(inst, issues);
389
+ inst.name = "ZodError";
390
+ Object.defineProperties(inst, {
391
+ format: {
392
+ value: (mapper) => formatError(inst, mapper)
393
+ // enumerable: false,
394
+ },
395
+ flatten: {
396
+ value: (mapper) => flattenError(inst, mapper)
397
+ // enumerable: false,
398
+ },
399
+ addIssue: {
400
+ value: (issue2) => {
401
+ inst.issues.push(issue2);
402
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
403
+ }
404
+ // enumerable: false,
405
+ },
406
+ addIssues: {
407
+ value: (issues2) => {
408
+ inst.issues.push(...issues2);
409
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
410
+ }
411
+ // enumerable: false,
412
+ },
413
+ isEmpty: {
414
+ get() {
415
+ return inst.issues.length === 0;
416
+ }
417
+ // enumerable: false,
418
+ }
419
+ });
421
420
  };
421
+ var ZodError = $constructor("ZodError", initializer2);
422
422
 
423
423
  // src/index.ts
424
424
  var _hasPermissionPromise;
@@ -698,17 +698,18 @@ var MastraServer = class extends serverAdapter.MastraServer {
698
698
  if (params.queryParams) {
699
699
  try {
700
700
  params.queryParams = await this.parseQueryParams(route, params.queryParams);
701
- } catch (error$1) {
701
+ } catch (error) {
702
702
  this.mastra.getLogger()?.error("Error parsing query params", {
703
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
703
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
704
704
  });
705
- if (error$1 instanceof ZodError) {
706
- return c.json(error.formatZodError(error$1, "query parameters"), 400);
705
+ if (error instanceof ZodError) {
706
+ const { status, body } = this.resolveValidationError(route, error, "query");
707
+ return c.json(body, status);
707
708
  }
708
709
  return c.json(
709
710
  {
710
711
  error: "Invalid query parameters",
711
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
712
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
712
713
  },
713
714
  400
714
715
  );
@@ -717,17 +718,18 @@ var MastraServer = class extends serverAdapter.MastraServer {
717
718
  if (params.body) {
718
719
  try {
719
720
  params.body = await this.parseBody(route, params.body);
720
- } catch (error$1) {
721
+ } catch (error) {
721
722
  this.mastra.getLogger()?.error("Error parsing body", {
722
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
723
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
723
724
  });
724
- if (error$1 instanceof ZodError) {
725
- return c.json(error.formatZodError(error$1, "request body"), 400);
725
+ if (error instanceof ZodError) {
726
+ const { status, body } = this.resolveValidationError(route, error, "body");
727
+ return c.json(body, status);
726
728
  }
727
729
  return c.json(
728
730
  {
729
731
  error: "Invalid request body",
730
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
732
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
731
733
  },
732
734
  400
733
735
  );
@@ -736,17 +738,18 @@ var MastraServer = class extends serverAdapter.MastraServer {
736
738
  if (params.urlParams) {
737
739
  try {
738
740
  params.urlParams = await this.parsePathParams(route, params.urlParams);
739
- } catch (error$1) {
741
+ } catch (error) {
740
742
  this.mastra.getLogger()?.error("Error parsing path params", {
741
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
743
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
742
744
  });
743
- if (error$1 instanceof ZodError) {
744
- return c.json(error.formatZodError(error$1, "path parameters"), 400);
745
+ if (error instanceof ZodError) {
746
+ const { status, body } = this.resolveValidationError(route, error, "path");
747
+ return c.json(body, status);
745
748
  }
746
749
  return c.json(
747
750
  {
748
751
  error: "Invalid path parameters",
749
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
752
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
750
753
  },
751
754
  400
752
755
  );
@@ -889,14 +892,14 @@ var MastraServer = class extends serverAdapter.MastraServer {
889
892
  const method = c.req.method;
890
893
  const path = c.req.path;
891
894
  await next();
892
- const duration = Date.now() - start;
895
+ const duration2 = Date.now() - start;
893
896
  const status = c.res.status;
894
897
  const level = this.httpLoggingConfig?.level || "info";
895
898
  const logData = {
896
899
  method,
897
900
  path,
898
901
  status,
899
- duration: `${duration}ms`
902
+ duration: `${duration2}ms`
900
903
  };
901
904
  if (this.httpLoggingConfig?.includeQueryParams) {
902
905
  logData.query = c.req.query();
@@ -912,7 +915,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
912
915
  });
913
916
  logData.headers = headers;
914
917
  }
915
- this.logger[level](`${method} ${path} ${status} ${duration}ms`, logData);
918
+ this.logger[level](`${method} ${path} ${status} ${duration2}ms`, logData);
916
919
  });
917
920
  }
918
921
  };