Repository navigation
fix(artifact): vega-lite charts no longer fail check_artifact with "Script error" - #4401
Conversation
…cript error" base() links the vendored DS sheet (pl-embed.css) into every frame, but the chart frame's CSP was style-src 'unsafe-inline', so the sheet was refused on every chart. ERRBOOT's capture-phase error listener also receives resource load failures; the refused <link>'s error event had no message, so it was reported as "Script error" with a failed render verdict, even though the chart drew fine. - vegaDoc's style-src now names exactly the vendored pl-embed.css. - ERRBOOT ignores stylesheet/image load failures (cosmetic, never a render failure) and names a <script> that failed to load; real script errors still report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 42 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
QA panel review — PASS
code-review-structural · head ee39af9d4ad4 · formal
No findings were raised, so there was nothing to verify. The panel (including the protoPatch structural pass) reviewed the two changes — the pl-embed.css CSP admission and the ERRBOOT resource-load failure filter — and found them correct and well-scoped. No coverage gaps identified.
No findings — the review came back clean.
findings JSON (machine-readable)
[]
Live verification: isolated instance (
|
Problem (launch bug B3)
Asked "Show a vega-lite bar chart of monthly revenue Jan–Jun: 12k,15k,14k,19k,23k,28k.",
check_artifactreported "Script error" on 3 valid specs. The agent burned versions and fell back to Chart.js (~54 s). The console logged a CSP violation each time:Loading the stylesheet '/plugins/artifact/vendor/pl-embed.css' violates … "style-src 'unsafe-inline'".Root cause
The CSS failure is what produced the script error:
base()links the vendored DS element-default sheetpl-embed.css(security: opt-in CIDR allowlist for A2A callbacks + peer_consult (#572) #577) into every frame.vegaDoc(the onlybase()frame that runs under a CSP) allowedstyle-src 'unsafe-inline'only, so the sheet was refused on every chart.errorlistener in the capture phase, so it also receives non-bubbling resource-load failures. The refused<link>'serrorevent carries nomessage, so ERRBOOT fell through to"⚠ Script error"and posted a failed render verdict. The chart itself had drawn fine: in a browser onmain, the frame had a 724px SVG under the red "⚠ Script error" overlay.No cross-origin script was involved: the vendored libraries already load with
crossorigin="anonymous"andACAO: *.Fix
vegaDocCSP:style-src 'unsafe-inline' <origin>/plugins/artifact/vendor/pl-embed.css. This allows exactly that one vendored file, not a host-wide grant.error(target is an element) no longer fails the render, except that a<script>which failed to load is reported by name (⚠ a script failed to load: <src>). A stylesheet or image failure is cosmetic. Real script errors (target is the window) still report as before. This also stops a broken<img>in an html artifact from being reported as "Script error".Chart width: on this build the chart already fills the card (
width:"container"+fit-x; 724 of 760 px in the embed, and full width in the chat card and the panel). The earlier "half width" look matched the failed-render overlay state, so no layout change was needed.Tests
test_the_chart_csp_admits_the_vendored_embed_stylesheet(tests/test_artifact_vega.py)test_a_resource_load_failure_is_not_a_script_errorandtest_a_real_script_error_still_reports(tests/test_artifact_embed.py), which run the real ERRBOOT source under nodeThe first two fail on
main.tests/test_artifact_embed.pyandtests/test_artifact_vega.pyall pass (70 passed, 1 skipped). Live verification is in a comment.🤖 Generated with Claude Code