Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: dropdown options parsing error

MonsPropre4578b37d582c
diff --git a/apps/api/src/task/validate-task-fields.ts b/apps/api/src/task/validate-task-fields.ts
index 9eb506247..bcda501b8 100644
--- a/apps/api/src/task/validate-task-fields.ts
+++ b/apps/api/src/task/validate-task-fields.ts
@@ -50,11 +50,17 @@ export async function assertRequiredCustomFields(
});
}
if (def.type === "dropdown") {
- const options: string[] = Array.isArray(def.options)
- ? def.options
- : typeof def.options === "string"
- ? JSON.parse(def.options)
- : [];
+ let options: string[] = Array.isArray(def.options) ? def.options : [];
+
+ if (typeof def.options === "string") {
+ try {
+ options = JSON.parse(def.options);
+ } catch {
+ throw new HTTPException(400, {
+ message: `Custom field "${def.name}" has invalid dropdown options.`,
+ });
+ }
+ }
if (!options.includes(cf.value.trim())) {
throw new HTTPException(400, {