fix(api): parse path ids with a rowId pipe that answers like an unknown id

RowIdPipe (src/nest/common/row-id.pipe.ts) parses a path param with toRowId. It answers a refused spelling with the route's own not-found answer, so '0x5', '5e0' and 'abc' get what an id that names no row gets. ParseRowIdPipe replaces Nest's ParseIntPipe with the same 400 and message: ParseIntPipe let '-1' and numbers past 2^53 through, and Postgres refuses the latter as out of range. Journey, journey recordings, day import, book design, map, public photo, collections, doc-sync, vacay, atlas and the plugin user-data export declare their ids through it. The upload routes parse in the handler with withRowId, so a refused id takes the existing cleanup path, or carry SpoolCleanupInterceptor (collections).
This commit is contained in:
Maurice
2026-11-18 13:20:05 +01:00
parent 7f6f2eb97c
commit 3eac508baf
28 changed files with 545 additions and 398 deletions
@@ -8,6 +8,7 @@ import { AdminGuard } from '../auth-core/admin.guard';
import { CurrentUser } from '../auth-core/current-user.decorator';
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
import { ManagedForbidden, isManagedBlocked, MANAGED_FORBIDDEN_ERROR } from '../common/managed';
import { rowId } from '../common/row-id.pipe';
import { DependencyCycleError } from './dependencies';
import { devLinkEnabled } from './dev-link';
import { pluginsEnabled } from './kill-switch';
@@ -430,9 +431,8 @@ export class PluginsController {
* user, for an admin fulfilling a data-access request. Literal-prefixed path, so it
* never collides with the :id routes. */
@Get('user-data/:userId/export')
async exportUserData(@Param('userId') userId: string) {
const id = Number(userId);
if (!Number.isInteger(id) || id <= 0) throw new HttpException({ error: 'invalid user id' }, 400);
async exportUserData(@Param('userId', rowId('invalid user id', 400)) id: number) {
if (id <= 0) throw new HttpException({ error: 'invalid user id' }, 400);
return { userId: id, plugins: await this.runtime.exportUserData(id) };
}