report card: fix unterminated regex literal that breaks every chart#5
Open
yurekami wants to merge 1 commit into
Open
report card: fix unterminated regex literal that breaks every chart#5yurekami wants to merge 1 commit into
yurekami wants to merge 1 commit into
Conversation
The id-escape regex used by the Plotly->DataTables click handler is unterminated as written: inside the character class, the parser reads `\]\\]` as literal `]`, literal `\`, escaped `]`, consuming the closing `]` of the class. JS raises `SyntaxError: Invalid regular expression: missing /` at parse time. Both occurrences sit in the main <script> block (1002-1201), so the SyntaxError aborts the whole block -- Plotly chart drawing and click-to-jump never run on any rendered report card. Drop one backslash so the class closes after `\]\` + `]`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Plotly→DataTables click handler in the HTML report card escapes user IDs with a regex that is syntactically invalid: the character class is unterminated, so JavaScript fails at parse time with
SyntaxError: Invalid regular expression: missing /. Because both occurrences sit inside the main<script>block (lines 1002–1201), the error aborts the entire block, so the Plotly correlation/runtime/robustness charts never render and click-to-jump never wires up on any report card AutoMetrics emits.This is purely a typo: one extra backslash before the closing
]of the class.What's wrong
Inside
[...]the parser reads:\]→ literal]\→ literal\\]→ escaped]← consumes what should be the closing bracket of the class…so the class never terminates and the regex literal is unparseable. Verified directly in V8:
Fix
Drop one backslash so the class closes after
\]+\+]. This is the standard MDN regex-metachar escape class.Code changes
autometrics/util/report_card.py:\before the closing]of the class.Two single-character changes; no behaviour intent changed — this is what the surrounding code obviously meant to do.
Verification
Why this slipped through
The bug only manifests at JS parse time in the rendered HTML; pytest doesn't execute the embedded script, and the existing
test_report_card_pvalue.pyonly asserts presence of substrings in the rendered HTML, not that the JS parses. (Happy to add a tinyjs2py/nodesmoke test as a follow-up if the maintainers want it, but kept this PR to the one-line fix.)