From e274ae107dbb47a4354fc143b173080281b6d7c9 Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Wed, 14 Jan 2026 16:05:09 +0100 Subject: [PATCH 1/3] fix: `FieldErrors` function returned array instead of an object --- src/util/util/FieldError.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/util/util/FieldError.ts b/src/util/util/FieldError.ts index 8f93b2b6e..76b34b821 100644 --- a/src/util/util/FieldError.ts +++ b/src/util/util/FieldError.ts @@ -29,19 +29,20 @@ export type ErrorContent = { code: string; message: string }; export type ObjectErrorContent = { _errors: ErrorContent[] }; export function FieldErrors(fields: Record, errors?: ErrorObject[]) { - return new FieldError( - 50035, - "Invalid Form Body", - Object.values(fields).map(({ message, code }) => ({ + const errorsObject = {} as Record; + + Object.entries(fields).map(([key, { message, code }]) => { + errorsObject[key] = { _errors: [ { message, code: code || "BASE_TYPE_INVALID", }, ], - })), - errors, - ); + }; + }); + + return new FieldError(50035, "Invalid Form Body", errorsObject, errors); } // TODO: implement Image data type: Data URI scheme that supports JPG, GIF, and PNG formats. An example Data URI format is: data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA From 349211bdcd414efffb2f38fb3b0b3ea7747e19a7 Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Wed, 14 Jan 2026 16:11:36 +0100 Subject: [PATCH 2/3] fest: throw an error if application name is empty --- src/api/routes/applications/#application_id/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/api/routes/applications/#application_id/index.ts b/src/api/routes/applications/#application_id/index.ts index 1576df88e..58c01568e 100644 --- a/src/api/routes/applications/#application_id/index.ts +++ b/src/api/routes/applications/#application_id/index.ts @@ -17,7 +17,7 @@ */ import { route } from "@spacebar/api"; -import { Application, DiscordApiErrors, Guild, handleFile, User } from "@spacebar/util"; +import { Application, DiscordApiErrors, FieldErrors, Guild, handleFile, User } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; import { verifyToken } from "node-2fa"; @@ -73,6 +73,15 @@ router.patch( if (app.owner.totp_secret && (!req.body.code || verifyToken(app.owner.totp_secret, req.body.code))) throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008); + if (body.name?.trim() == "") { + throw FieldErrors({ + name: { + code: "BASE_TYPE_REQUIRED", + message: req.t("common:field.BASE_TYPE_REQUIRED"), + }, + }); + } + if (body.icon) { body.icon = await handleFile(`/app-icons/${app.id}`, body.icon as string); } From e2df7c892710e378b7191110cc7817612d161f67 Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Wed, 14 Jan 2026 16:17:13 +0100 Subject: [PATCH 3/3] fest: throw an error if bot name is empty --- assets/openapi.json | Bin 863404 -> 863500 bytes assets/schemas.json | Bin 381142 -> 381214 bytes .../applications/#application_id/bot/index.ts | 11 ++++++++++- src/schemas/uncategorised/BotModifySchema.ts | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/assets/openapi.json b/assets/openapi.json index 78204ccbb0c08ff8c3d45f096fce12c174e34b1a..19447b164d28a11da13dde009723deb7d3e5bea4 100644 GIT binary patch delta 67 zcmZ2;)1>E?Nka?c7A7^bX|GrlCO7!%w}+ZB0WmWWvj8zG5VHX>I}mdKF((jn0WtUX JP&1zJZvZs#7H