{"record":{"id":"84ed517e96ec0037","repo":"octobercms/october","slug":"error-parsing-the-name-attribute-value-e-84ed51","errorCode":null,"errorMessage":"Error parsing the ${name} attribute value. ${e}","messagePattern":"Error parsing the (.+?) attribute value\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"modules/system/assets/js/framework.js","lineNumber":2052,"sourceCode":"  var namespace_default = Request;\n\n  // ../../vendor/larajax/larajax/resources/src/util/json-parser.js\n  var JsonParser = class _JsonParser {\n    // Public\n    static paramToObj(name, value) {\n      if (value === void 0) {\n        value = \"\";\n      }\n      if (typeof value === \"object\") {\n        return value;\n      }\n      if (value.charAt(0) !== \"{\") {\n        value = \"{\" + value + \"}\";\n      }\n      try {\n        return this.parseJSON(value);\n      } catch (e) {\n        throw new Error(\"Error parsing the \" + name + \" attribute value. \" + e);\n      }\n    }\n    static parseJSON(json) {\n      return JSON.parse(new _JsonParser().parseString(json));\n    }\n    // Private\n    parseString(str) {\n      str = str.trim();\n      if (!str.length) {\n        throw new Error(\"Broken JSON object.\");\n      }\n      var result = \"\";\n      while (str && str[0] === \",\") {\n        str = str.substr(1);\n      }\n      if (str[0] === '\"' || str[0] === \"'\") {\n        if (str[str.length - 1] !== str[0]) {\n          throw new Error(\"Invalid string JSON object.\");","sourceCodeStart":2034,"sourceCodeEnd":2070,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/system/assets/js/framework.js#L2034-L2070","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"<!-- before -->\n<div data-request=\"onRefresh\" data-request-update=\"{'items': '#list'\">...</div>\n\n<!-- after -->\n<div data-request=\"onRefresh\" data-request-update=\"{'items': '#list'}\">...</div>","handlingStrategy":"validation","validationCode":"function dataAttrsAreValid(el) {\n  return ['data-request-data', 'data-request-update', 'data-request-query'].every((a) => {\n    const raw = el.getAttribute(a);\n    if (!raw) return true;\n    try { oc.parseJSON(raw.charAt(0) === '{' ? raw : '{' + raw + '}'); return true; }\n    catch { return false; }\n  });\n}\n\nif (dataAttrsAreValid(el)) oc.request(el, 'onGo');","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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"],"tags":["json","ajax","html-attribute","parser","frontend"],"backgroundTag":"invalid-json-attribute","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}