octobercms/october · error · Error
Error parsing the ${name} attribute value. ${e}
Error message
Error parsing the ${name} attribute value. ${e} What it means
Thrown by JsonParser.paramToObj(name, value) in October CMS's framework.js when an element attribute meant to hold relaxed JSON (data-request-data, data-request-update, data-request-query, ajaxRequestUpdate metadata, ...) fails to parse. The value is brace-wrapped if needed, handed to the lenient parser, and any failure is rethrown with the attribute name plus the underlying reason - so the message identifies both the attribute and the syntax problem.
Source
Thrown at modules/system/assets/js/framework.js:2052
var namespace_default = Request;
// ../../vendor/larajax/larajax/resources/src/util/json-parser.js
var JsonParser = class _JsonParser {
// Public
static paramToObj(name, value) {
if (value === void 0) {
value = "";
}
if (typeof value === "object") {
return value;
}
if (value.charAt(0) !== "{") {
value = "{" + value + "}";
}
try {
return this.parseJSON(value);
} catch (e) {
throw new Error("Error parsing the " + name + " attribute value. " + e);
}
}
static parseJSON(json) {
return JSON.parse(new _JsonParser().parseString(json));
}
// Private
parseString(str) {
str = str.trim();
if (!str.length) {
throw new Error("Broken JSON object.");
}
var result = "";
while (str && str[0] === ",") {
str = str.substr(1);
}
if (str[0] === '"' || str[0] === "'") {
if (str[str.length - 1] !== str[0]) {
throw new Error("Invalid string JSON object.");View on GitHub (pinned to b608633a7e)
Solutions
- Use the attribute name + inner message in the error to locate and fix the exact markup defect
- Validate in the console: oc.parseJSON(el.getAttribute('data-request-update')) until clean
- Author these attributes via JSON.stringify/json_encode rather than by hand
- Add a lint step (or page-ready sanity check) that round-trips all data-request-* attributes on interactive elements
Example fix
<!-- before -->
<div data-request="onRefresh" data-request-update="{'items': '#list'">...</div>
<!-- after -->
<div data-request="onRefresh" data-request-update="{'items': '#list'}">...</div> Defensive patterns
Strategy: validation
Validate before calling
function dataAttrsAreValid(el) {
return ['data-request-data', 'data-request-update', 'data-request-query'].every((a) => {
const raw = el.getAttribute(a);
if (!raw) return true;
try { oc.parseJSON(raw.charAt(0) === '{' ? raw : '{' + raw + '}'); return true; }
catch { return false; }
});
}
if (dataAttrsAreValid(el)) oc.request(el, 'onGo'); Try / catch
try { oc.request(el, 'onGo'); } catch (e) { if (/Error parsing the .* attribute value/.test(e.message)) { console.error('Broken data attribute on', el, e.message); return; } throw e; } Prevention
- Validate all data-request-* attributes during development with a page-ready sweep
- Generate attributes with JSON.stringify; avoid hand-editing relaxed JSON in markup
- Log element.outerHTML with the failure to speed up markup fixes
When it happens
Trigger: oc.request(el) fires and the framework reads el's data-request-data="{a: 1" (truncated), data-request-update with unbalanced brackets, or any attribute where the relaxed parse fails; the chained 'Broken JSON ...' text names the exact sub-problem.
Common situations: Hand-authored data attributes with typos or truncation; template output breaking quotes; CMS-managed markup fields containing invalid JSON; partials updated by AJAX carrying broken attributes into the DOM.
Related errors
- Broken JSON boolean body near ${str}
- Error parsing the ${name} attribute value. ${e}
- Broken JSON number body near ${body}
- Broken JSON ${str[pos] === "{" ? "object" : "array"} body ne
- Broken JSON body near ${str}
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/84ed517e96ec0037.
Report an issue: GitHub.