@buka/nestjs-kit 4.4.13 → 4.5.0

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/dist/index.mjs CHANGED
@@ -1325,6 +1325,13 @@ let BukaPageQueryValidationPipe = class BukaPageQueryValidationPipe {
1325
1325
  if (metadata.type !== "query") throw new InternalServerErrorException("BukaPageQueryValidationPipe can only be used to validate query parameters.");
1326
1326
  if (!value.page) if (this.options.optional) return value;
1327
1327
  else throw new BadRequestException("Missing required query parameter: page");
1328
+ /**
1329
+ * 走到这里时 `value.page` 已非空,但 query string 可能把 `page` 解析为标量
1330
+ * (如 `?page=1` 解析为字符串 `"1"`),对原始值使用 `in` 运算符会抛 TypeError,
1331
+ * 冒泡到全局异常过滤器后被映射为 500。先保证 `page` 是纯对象,数组一并拦截,
1332
+ * 使非法形态收敛为 400。
1333
+ */
1334
+ if (typeof value.page !== "object" || Array.isArray(value.page)) throw new BadRequestException("Invalid page query: page must be an object.");
1328
1335
  const mode = this.options.mode;
1329
1336
  if ((!mode || mode === "offset") && ("limit" in value.page || "offset" in value.page)) {
1330
1337
  if ("after" in value.page || "first" in value.page || "before" in value.page || "last" in value.page) throw new BadRequestException(mixedOffsetAndCursorError);