mirror of
https://github.com/monoscope-tech/monoscope.git
synced 2026-11-16 10:18:01 +00:00
Stop corrupting chart JSON by interpolating it into a template literal
The widget's ECharts options were embedded as `${echartOpt}` inside a JS
template literal. A template literal unescapes before JSON.parse runs, so every
\" in a value collapsed to a bare " and the parse died with "Expected ',' or '}'
after property value". That was harmless while no option value contained a
quote. e09d27e9a added a unit-aware label.formatter — a function string, with
quotes in it — and every chart on the page stopped initialising.
It presented as four unrelated e2e failures: two "no client-side errors" and two
metrics-catalog assertions seeing zero data, because parseAndInit throws before
any chart is built.
Encode twice instead: the first produces JSON, the second makes that JSON a JS
string literal, which is what the slot actually needs. The one adjacent
instance of the same shape — stored SQL in `${querySQL}`, where a backtick or a
${…} would end the literal — is fixed the same way.
The e2e assertion now reports e.stack rather than String(e); a bare
"SyntaxError: Expected ',' or '}'" names neither file nor call site, which is
what made this cost a bisect instead of a glance.
This commit is contained in:
parent
a54181795e
commit
6bfc9434f7
2 changed files with 18 additions and 5 deletions
Loading…
Add table
Add a link
Reference in a new issue