{"record":{"id":"f57284f32c0953de","repo":"octobercms/october","slug":"broken-json-boolean-body-near-str-f57284","errorCode":null,"errorMessage":"Broken JSON boolean body near ${str}","messagePattern":"Broken JSON boolean body near (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"modules/system/assets/js/framework.js","lineNumber":2226,"sourceCode":"            i++;\n          } else if (str[i] === str[pos]) {\n            body += str[pos];\n            return {\n              originLength: body.length,\n              body\n            };\n          } else body += str[i];\n        }\n        throw new Error(\"Broken JSON string body near \" + body);\n      }\n      if (str[pos] === \"t\") {\n        if (str.indexOf(\"true\", pos) === pos) {\n          return {\n            originLength: \"true\".length,\n            body: \"true\"\n          };\n        }\n        throw new Error(\"Broken JSON boolean body near \" + str.substr(0, pos + 10));\n      }\n      if (str[pos] === \"f\") {\n        if (str.indexOf(\"f\", pos) === pos) {\n          return {\n            originLength: \"false\".length,\n            body: \"false\"\n          };\n        }\n        throw new Error(\"Broken JSON boolean body near \" + str.substr(0, pos + 10));\n      }\n      if (str[pos] === \"n\") {\n        if (str.indexOf(\"null\", pos) === pos) {\n          return {\n            originLength: \"null\".length,\n            body: \"null\"\n          };\n        }\n        throw new Error(\"Broken JSON boolean body near \" + str.substr(0, pos + 10));","sourceCodeStart":2208,"sourceCodeEnd":2244,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/system/assets/js/framework.js#L2208-L2244","documentation":"Part of the same lenient JSON scanner: getBody() dispatches on the first character of a value, so any unquoted token starting with 't' is assumed to be the boolean literal true. If the next four characters are not exactly \"true\" (e.g. \"tru\", \"ture\", \"trueX\", \"test\"), the parser throws this error. It fires during oc.parseJSON, i.e. whenever a data-* attribute like data-request-data is parsed.","triggerScenarios":"An unquoted string value starting with t: data-request-data=\"filter: today\" (wrapped to {filter: today}); a boolean typo such as {enabled: ture} or {flag: tru}; a capitalized boolean {ok: True} does NOT hit this branch (it falls through to the generic 'Broken JSON body' error) — only lowercase t-prefixed tokens do.","commonSituations":"Authors writing shorthand attribute configs (key: value) and forgetting quotes around text values; booleans mistyped; migrating jQuery-era inline options into data attributes.","solutions":["Quote the string value if it is text: {filter: 'today'} or filter: \"today\".","If a boolean was intended, correct the spelling to the exact lowercase literal true.","Remember the rule: only bare true/false/null are allowed unquoted; everything else must be quoted."],"exampleFix":"// before\n<a data-request=\"onFilter\" data-request-data=\"filter: today\">Today</a>\n\n// after\n<a data-request=\"onFilter\" data-request-data=\"{filter: 'today'}\">Today</a>","handlingStrategy":"validation","validationCode":"// Allow only true/false/null unquoted; everything else must be quoted\nfunction validBareTokens(value) {\n    return value.replace(/'[^']*'|\"[^\"]*\"/g, '').match(/:(?:\\s*)(t(?!rue\\b)|f(?!alse\\b)|n(?!ull\\b))\\w/i) === null;\n}","typeGuard":null,"tryCatchPattern":"try { oc.parseJSON(raw); } catch (e) { /* treat attribute as absent and log */ console.warn('Ignoring malformed config:', e.message); }","preventionTips":["Adopt the rule 'only true/false/null go bare' in code review for markup.","Prefer fully JSON (quoted keys and strings) in generated markup; keep the lenient syntax only for hand-written shorthand.","When a value starts with t/f/n and is text, quote it."],"tags":["json","parsing","frontend","data-attribute","boolean-literal"],"backgroundTag":"invalid-json-literal","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}