From 5fc82993904e1f92cb9774d78ddb9e290be783e7 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 27 Oct 2022 17:52:28 +0100 Subject: [PATCH] Patch: Throw 404 if row not found --- packages/server/src/api/controllers/row/ExternalRequest.ts | 4 +--- packages/server/src/api/controllers/row/index.ts | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index 0af6ed12af..4463dabd5a 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -286,9 +286,7 @@ module External { if (isNaN(id)) { id = decodeURIComponent(row[key]).match(/\[(.*?)\]/)?.[1] } - newRow[field.foreignKey || linkTablePrimary] = breakRowIdField( - id - )[0] + newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(id)[0] } // many to many else if (field.through) { diff --git a/packages/server/src/api/controllers/row/index.ts b/packages/server/src/api/controllers/row/index.ts index 901589970b..55af998759 100644 --- a/packages/server/src/api/controllers/row/index.ts +++ b/packages/server/src/api/controllers/row/index.ts @@ -37,6 +37,9 @@ export async function patch(ctx: any): Promise { datasourceId: tableId, } ) + if (!row) { + ctx.throw(404, "Row not found!") + } ctx.status = 200 ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:update`, appId, row, table)