From d288b2b71c8c012e33c92cfc217936c6c61c03df Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Mon, 9 Mar 2026 13:15:19 -0700 Subject: [PATCH] Add JSON parse error debug logging in saveWizard Co-Authored-By: Claude Opus 4.6 --- api/setup/saveWizard.cfm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/api/setup/saveWizard.cfm b/api/setup/saveWizard.cfm index dcc1bbd..6bd1b1a 100644 --- a/api/setup/saveWizard.cfm +++ b/api/setup/saveWizard.cfm @@ -145,7 +145,21 @@ try { // Clean control characters that Lucee's JSON parser can't handle requestBody = reReplace(requestBody, "[\x00-\x08\x0B\x0C\x0E-\x1F]", "", "all"); - data = deserializeJSON(requestBody); + try { + data = deserializeJSON(requestBody); + } catch (any jsonErr) { + // Log snippet around error for debugging + nums = reMatch("\d+", jsonErr.message); + errorPos = 0; + for (n in nums) { if (val(n) > 1000) { errorPos = val(n); break; } } + if (errorPos > 0) { + snippet = mid(requestBody, max(1, errorPos - 100), 250); + arrayAppend(response.errors, "JSON parse failed near position #errorPos#: [#snippet#]"); + } + arrayAppend(response.errors, jsonErr.message); + writeOutput(serializeJSON(response)); + abort; + } businessId = structKeyExists(data, "businessId") ? val(data.businessId) : 0; userId = structKeyExists(data, "userId") ? val(data.userId) : 0;