@mastra/koa 1.2.5 → 1.3.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/koa
2
2
 
3
+ ## 1.3.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.3.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.2.5
4
42
 
5
43
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -2,217 +2,217 @@
2
2
 
3
3
  var busboy = require('@fastify/busboy');
4
4
  var auth = require('@mastra/server/auth');
5
- var error = require('@mastra/server/handlers/error');
6
5
  var serverAdapter = require('@mastra/server/server-adapter');
7
6
 
8
7
  // src/index.ts
9
-
10
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
11
- var util;
12
- (function(util2) {
13
- util2.assertEqual = (_) => {
14
- };
15
- function assertIs(_arg) {
16
- }
17
- util2.assertIs = assertIs;
18
- function assertNever(_x) {
19
- throw new Error();
20
- }
21
- util2.assertNever = assertNever;
22
- util2.arrayToEnum = (items) => {
23
- const obj = {};
24
- for (const item of items) {
25
- obj[item] = item;
8
+ // @__NO_SIDE_EFFECTS__
9
+ function $constructor(name, initializer3, params) {
10
+ function init(inst, def) {
11
+ if (!inst._zod) {
12
+ Object.defineProperty(inst, "_zod", {
13
+ value: {
14
+ def,
15
+ constr: _,
16
+ traits: /* @__PURE__ */ new Set()
17
+ },
18
+ enumerable: false
19
+ });
26
20
  }
27
- return obj;
28
- };
29
- util2.getValidEnumValues = (obj) => {
30
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
31
- const filtered = {};
32
- for (const k of validKeys) {
33
- filtered[k] = obj[k];
21
+ if (inst._zod.traits.has(name)) {
22
+ return;
34
23
  }
35
- return util2.objectValues(filtered);
36
- };
37
- util2.objectValues = (obj) => {
38
- return util2.objectKeys(obj).map(function(e) {
39
- return obj[e];
40
- });
41
- };
42
- util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
43
- const keys = [];
44
- for (const key in object) {
45
- if (Object.prototype.hasOwnProperty.call(object, key)) {
46
- keys.push(key);
24
+ inst._zod.traits.add(name);
25
+ initializer3(inst, def);
26
+ const proto = _.prototype;
27
+ const keys = Object.keys(proto);
28
+ for (let i = 0; i < keys.length; i++) {
29
+ const k = keys[i];
30
+ if (!(k in inst)) {
31
+ inst[k] = proto[k].bind(inst);
47
32
  }
48
33
  }
49
- return keys;
50
- };
51
- util2.find = (arr, checker) => {
52
- for (const item of arr) {
53
- if (checker(item))
54
- return item;
34
+ }
35
+ const Parent = params?.Parent ?? Object;
36
+ class Definition extends Parent {
37
+ }
38
+ Object.defineProperty(Definition, "name", { value: name });
39
+ function _(def) {
40
+ var _a2;
41
+ const inst = params?.Parent ? new Definition() : this;
42
+ init(inst, def);
43
+ (_a2 = inst._zod).deferred ?? (_a2.deferred = []);
44
+ for (const fn of inst._zod.deferred) {
45
+ fn();
55
46
  }
56
- return void 0;
57
- };
58
- util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
59
- function joinValues(array, separator = " | ") {
60
- return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
47
+ return inst;
61
48
  }
62
- util2.joinValues = joinValues;
63
- util2.jsonStringifyReplacer = (_, value) => {
64
- if (typeof value === "bigint") {
65
- return value.toString();
49
+ Object.defineProperty(_, "init", { value: init });
50
+ Object.defineProperty(_, Symbol.hasInstance, {
51
+ value: (inst) => {
52
+ if (params?.Parent && inst instanceof params.Parent)
53
+ return true;
54
+ return inst?._zod?.traits?.has(name);
66
55
  }
67
- return value;
68
- };
69
- })(util || (util = {}));
70
- var objectUtil;
71
- (function(objectUtil2) {
72
- objectUtil2.mergeShapes = (first, second) => {
73
- return {
74
- ...first,
75
- ...second
76
- // second overwrites first
77
- };
78
- };
79
- })(objectUtil || (objectUtil = {}));
80
- util.arrayToEnum([
81
- "string",
82
- "nan",
83
- "number",
84
- "integer",
85
- "float",
86
- "boolean",
87
- "date",
88
- "bigint",
89
- "symbol",
90
- "function",
91
- "undefined",
92
- "null",
93
- "array",
94
- "object",
95
- "unknown",
96
- "promise",
97
- "void",
98
- "never",
99
- "map",
100
- "set"
101
- ]);
56
+ });
57
+ Object.defineProperty(_, "name", { value: name });
58
+ return _;
59
+ }
102
60
 
103
- // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
104
- util.arrayToEnum([
105
- "invalid_type",
106
- "invalid_literal",
107
- "custom",
108
- "invalid_union",
109
- "invalid_union_discriminator",
110
- "invalid_enum_value",
111
- "unrecognized_keys",
112
- "invalid_arguments",
113
- "invalid_return_type",
114
- "invalid_date",
115
- "invalid_string",
116
- "too_small",
117
- "too_big",
118
- "invalid_intersection_types",
119
- "not_multiple_of",
120
- "not_finite"
121
- ]);
122
- var ZodError = class _ZodError extends Error {
123
- get errors() {
124
- return this.issues;
125
- }
126
- constructor(issues) {
127
- super();
128
- this.issues = [];
129
- this.addIssue = (sub) => {
130
- this.issues = [...this.issues, sub];
131
- };
132
- this.addIssues = (subs = []) => {
133
- this.issues = [...this.issues, ...subs];
134
- };
135
- const actualProto = new.target.prototype;
136
- if (Object.setPrototypeOf) {
137
- Object.setPrototypeOf(this, actualProto);
61
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js
62
+ function jsonStringifyReplacer(_, value) {
63
+ if (typeof value === "bigint")
64
+ return value.toString();
65
+ return value;
66
+ }
67
+
68
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js
69
+ var initializer = (inst, def) => {
70
+ inst.name = "$ZodError";
71
+ Object.defineProperty(inst, "_zod", {
72
+ value: inst._zod,
73
+ enumerable: false
74
+ });
75
+ Object.defineProperty(inst, "issues", {
76
+ value: def,
77
+ enumerable: false
78
+ });
79
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
80
+ Object.defineProperty(inst, "toString", {
81
+ value: () => inst.message,
82
+ enumerable: false
83
+ });
84
+ };
85
+ var $ZodError = $constructor("$ZodError", initializer);
86
+ function flattenError(error, mapper = (issue2) => issue2.message) {
87
+ const fieldErrors = {};
88
+ const formErrors = [];
89
+ for (const sub of error.issues) {
90
+ if (sub.path.length > 0) {
91
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
92
+ fieldErrors[sub.path[0]].push(mapper(sub));
138
93
  } else {
139
- this.__proto__ = actualProto;
94
+ formErrors.push(mapper(sub));
140
95
  }
141
- this.name = "ZodError";
142
- this.issues = issues;
143
96
  }
144
- format(_mapper) {
145
- const mapper = _mapper || function(issue) {
146
- return issue.message;
147
- };
148
- const fieldErrors = { _errors: [] };
149
- const processError = (error) => {
150
- for (const issue of error.issues) {
151
- if (issue.code === "invalid_union") {
152
- issue.unionErrors.map(processError);
153
- } else if (issue.code === "invalid_return_type") {
154
- processError(issue.returnTypeError);
155
- } else if (issue.code === "invalid_arguments") {
156
- processError(issue.argumentsError);
157
- } else if (issue.path.length === 0) {
158
- fieldErrors._errors.push(mapper(issue));
159
- } else {
160
- let curr = fieldErrors;
161
- let i = 0;
162
- while (i < issue.path.length) {
163
- const el = issue.path[i];
164
- const terminal = i === issue.path.length - 1;
165
- if (!terminal) {
166
- curr[el] = curr[el] || { _errors: [] };
167
- } else {
168
- curr[el] = curr[el] || { _errors: [] };
169
- curr[el]._errors.push(mapper(issue));
170
- }
171
- curr = curr[el];
172
- i++;
97
+ return { formErrors, fieldErrors };
98
+ }
99
+ function formatError(error, mapper = (issue2) => issue2.message) {
100
+ const fieldErrors = { _errors: [] };
101
+ const processError = (error2) => {
102
+ for (const issue2 of error2.issues) {
103
+ if (issue2.code === "invalid_union" && issue2.errors.length) {
104
+ issue2.errors.map((issues) => processError({ issues }));
105
+ } else if (issue2.code === "invalid_key") {
106
+ processError({ issues: issue2.issues });
107
+ } else if (issue2.code === "invalid_element") {
108
+ processError({ issues: issue2.issues });
109
+ } else if (issue2.path.length === 0) {
110
+ fieldErrors._errors.push(mapper(issue2));
111
+ } else {
112
+ let curr = fieldErrors;
113
+ let i = 0;
114
+ while (i < issue2.path.length) {
115
+ const el = issue2.path[i];
116
+ const terminal = i === issue2.path.length - 1;
117
+ if (!terminal) {
118
+ curr[el] = curr[el] || { _errors: [] };
119
+ } else {
120
+ curr[el] = curr[el] || { _errors: [] };
121
+ curr[el]._errors.push(mapper(issue2));
173
122
  }
123
+ curr = curr[el];
124
+ i++;
174
125
  }
175
126
  }
176
- };
177
- processError(this);
178
- return fieldErrors;
179
- }
180
- static assert(value) {
181
- if (!(value instanceof _ZodError)) {
182
- throw new Error(`Not a ZodError: ${value}`);
183
127
  }
128
+ };
129
+ processError(error);
130
+ return fieldErrors;
131
+ }
132
+
133
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.js
134
+ var _a;
135
+ var $ZodRegistry = class {
136
+ constructor() {
137
+ this._map = /* @__PURE__ */ new WeakMap();
138
+ this._idmap = /* @__PURE__ */ new Map();
184
139
  }
185
- toString() {
186
- return this.message;
140
+ add(schema, ..._meta) {
141
+ const meta = _meta[0];
142
+ this._map.set(schema, meta);
143
+ if (meta && typeof meta === "object" && "id" in meta) {
144
+ this._idmap.set(meta.id, schema);
145
+ }
146
+ return this;
187
147
  }
188
- get message() {
189
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
148
+ clear() {
149
+ this._map = /* @__PURE__ */ new WeakMap();
150
+ this._idmap = /* @__PURE__ */ new Map();
151
+ return this;
190
152
  }
191
- get isEmpty() {
192
- return this.issues.length === 0;
153
+ remove(schema) {
154
+ const meta = this._map.get(schema);
155
+ if (meta && typeof meta === "object" && "id" in meta) {
156
+ this._idmap.delete(meta.id);
157
+ }
158
+ this._map.delete(schema);
159
+ return this;
193
160
  }
194
- flatten(mapper = (issue) => issue.message) {
195
- const fieldErrors = {};
196
- const formErrors = [];
197
- for (const sub of this.issues) {
198
- if (sub.path.length > 0) {
199
- const firstEl = sub.path[0];
200
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
201
- fieldErrors[firstEl].push(mapper(sub));
202
- } else {
203
- formErrors.push(mapper(sub));
204
- }
161
+ get(schema) {
162
+ const p = schema._zod.parent;
163
+ if (p) {
164
+ const pm = { ...this.get(p) ?? {} };
165
+ delete pm.id;
166
+ const f = { ...pm, ...this._map.get(schema) };
167
+ return Object.keys(f).length ? f : void 0;
205
168
  }
206
- return { formErrors, fieldErrors };
169
+ return this._map.get(schema);
207
170
  }
208
- get formErrors() {
209
- return this.flatten();
171
+ has(schema) {
172
+ return this._map.has(schema);
210
173
  }
211
174
  };
212
- ZodError.create = (issues) => {
213
- const error = new ZodError(issues);
214
- return error;
175
+ function registry() {
176
+ return new $ZodRegistry();
177
+ }
178
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
179
+
180
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/errors.js
181
+ var initializer2 = (inst, issues) => {
182
+ $ZodError.init(inst, issues);
183
+ inst.name = "ZodError";
184
+ Object.defineProperties(inst, {
185
+ format: {
186
+ value: (mapper) => formatError(inst, mapper)
187
+ // enumerable: false,
188
+ },
189
+ flatten: {
190
+ value: (mapper) => flattenError(inst, mapper)
191
+ // enumerable: false,
192
+ },
193
+ addIssue: {
194
+ value: (issue2) => {
195
+ inst.issues.push(issue2);
196
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
197
+ }
198
+ // enumerable: false,
199
+ },
200
+ addIssues: {
201
+ value: (issues2) => {
202
+ inst.issues.push(...issues2);
203
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
204
+ }
205
+ // enumerable: false,
206
+ },
207
+ isEmpty: {
208
+ get() {
209
+ return inst.issues.length === 0;
210
+ }
211
+ // enumerable: false,
212
+ }
213
+ });
215
214
  };
215
+ var ZodError = $constructor("ZodError", initializer2);
216
216
 
217
217
  // src/index.ts
218
218
  var _hasPermissionPromise;
@@ -628,19 +628,20 @@ var MastraServer = class extends serverAdapter.MastraServer {
628
628
  if (params.queryParams) {
629
629
  try {
630
630
  params.queryParams = await this.parseQueryParams(route, params.queryParams);
631
- } catch (error$1) {
631
+ } catch (error) {
632
632
  this.mastra.getLogger()?.error("Error parsing query params", {
633
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
633
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
634
634
  });
635
- if (error$1 instanceof ZodError) {
636
- ctx.status = 400;
637
- ctx.body = error.formatZodError(error$1, "query parameters");
635
+ if (error instanceof ZodError) {
636
+ const resolved = this.resolveValidationError(route, error, "query");
637
+ ctx.status = resolved.status;
638
+ ctx.body = resolved.body;
638
639
  return;
639
640
  }
640
641
  ctx.status = 400;
641
642
  ctx.body = {
642
643
  error: "Invalid query parameters",
643
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
644
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
644
645
  };
645
646
  return;
646
647
  }
@@ -648,19 +649,20 @@ var MastraServer = class extends serverAdapter.MastraServer {
648
649
  if (params.body) {
649
650
  try {
650
651
  params.body = await this.parseBody(route, params.body);
651
- } catch (error$1) {
652
+ } catch (error) {
652
653
  this.mastra.getLogger()?.error("Error parsing body", {
653
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
654
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
654
655
  });
655
- if (error$1 instanceof ZodError) {
656
- ctx.status = 400;
657
- ctx.body = error.formatZodError(error$1, "request body");
656
+ if (error instanceof ZodError) {
657
+ const resolved = this.resolveValidationError(route, error, "body");
658
+ ctx.status = resolved.status;
659
+ ctx.body = resolved.body;
658
660
  return;
659
661
  }
660
662
  ctx.status = 400;
661
663
  ctx.body = {
662
664
  error: "Invalid request body",
663
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
665
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
664
666
  };
665
667
  return;
666
668
  }
@@ -668,19 +670,20 @@ var MastraServer = class extends serverAdapter.MastraServer {
668
670
  if (params.urlParams) {
669
671
  try {
670
672
  params.urlParams = await this.parsePathParams(route, params.urlParams);
671
- } catch (error$1) {
673
+ } catch (error) {
672
674
  this.mastra.getLogger()?.error("Error parsing path params", {
673
- error: error$1 instanceof Error ? { message: error$1.message, stack: error$1.stack } : error$1
675
+ error: error instanceof Error ? { message: error.message, stack: error.stack } : error
674
676
  });
675
- if (error$1 instanceof ZodError) {
676
- ctx.status = 400;
677
- ctx.body = error.formatZodError(error$1, "path parameters");
677
+ if (error instanceof ZodError) {
678
+ const resolved = this.resolveValidationError(route, error, "path");
679
+ ctx.status = resolved.status;
680
+ ctx.body = resolved.body;
678
681
  return;
679
682
  }
680
683
  ctx.status = 400;
681
684
  ctx.body = {
682
685
  error: "Invalid path parameters",
683
- issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
686
+ issues: [{ field: "unknown", message: error instanceof Error ? error.message : "Unknown error" }]
684
687
  };
685
688
  return;
686
689
  }
@@ -833,14 +836,14 @@ var MastraServer = class extends serverAdapter.MastraServer {
833
836
  const method = ctx.method;
834
837
  const path = ctx.path;
835
838
  await next();
836
- const duration = Date.now() - start;
839
+ const duration2 = Date.now() - start;
837
840
  const status = ctx.status;
838
841
  const level = this.httpLoggingConfig?.level || "info";
839
842
  const logData = {
840
843
  method,
841
844
  path,
842
845
  status,
843
- duration: `${duration}ms`
846
+ duration: `${duration2}ms`
844
847
  };
845
848
  if (this.httpLoggingConfig?.includeQueryParams) {
846
849
  logData.query = ctx.query;
@@ -856,7 +859,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
856
859
  });
857
860
  logData.headers = headers;
858
861
  }
859
- this.logger[level](`${method} ${path} ${status} ${duration}ms`, logData);
862
+ this.logger[level](`${method} ${path} ${status} ${duration2}ms`, logData);
860
863
  });
861
864
  }
862
865
  };