From c8e7e543d65939c055d16895f5ed85676a8e2d8e Mon Sep 17 00:00:00 2001 From: Will Miao Date: Tue, 21 Jul 2026 22:09:30 +0800 Subject: [PATCH] fix(api): remove overstrict model type validation in getApiEndpoints The validation in getApiEndpoints threw for page types not in MODEL_TYPES (e.g. 'recipes'), crashing the recipes page initialization when FilterManager calls it via createBaseModelTags(). The throw was synchronous and outside the fetch().catch() chain, causing an uncaught promise rejection that aborted the entire app initialization. getApiEndpoints is a URL builder -- validation belongs to callers that need strict type checking (they already use isValidModelType()). For non-model-type pages like recipes, the generated URLs are correct (the backend does have /api/lm/recipes/* routes). Fixes regression from f53f859a (feat(filter): add debounced tag search). --- static/js/api/apiConfig.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/static/js/api/apiConfig.js b/static/js/api/apiConfig.js index 8673c929..13d628b7 100644 --- a/static/js/api/apiConfig.js +++ b/static/js/api/apiConfig.js @@ -49,10 +49,6 @@ export const MODEL_CONFIG = { * @returns {Object} Object containing all API endpoints for the model type */ export function getApiEndpoints(modelType) { - if (!Object.values(MODEL_TYPES).includes(modelType)) { - throw new Error(`Invalid model type: ${modelType}`); - } - return { // Base CRUD operations list: `/api/lm/${modelType}/list`,