Repository navigation
fix(cli): a theme warning prints as one line without control characters - #10764
Conversation
The configured astryx.theme value and the generated theme record come from the checkout. Every theme warning now replaces control and format characters with U+FFFD, so a newline or an escape sequence cannot rewrite the terminal. Carries the warning hardening from #5525. Co-authored-by: Baraa Hamodi <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 7740d42 |
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
Approved pending CI: the test jobs are still running on this head.
Theme warnings from astryx component now print the configured astryx.theme value and a generated record's owner as one line, with control and format characters shown as �; which theme loads is unchanged. The new cases fail without the fix and pass with it.
- Optional: the generated-record warning (
resolve-theme.mjs:114) and the "could not find a theme object" warning (:91) have no test that keeps them onwarnTheme; a case with a record owner that holds control characters would lock the path the changeset names.
[Automated review]
| it.each([ | ||
| ['a file path', './\u001b[2Jmissing.cjs'], | ||
| ['a scoped package', '@evil/\u001b]0;owned\u0007\npkg'], | ||
| ['a bare name', 'theme\u202e\r\nnext'], |
There was a problem hiding this comment.
Non-blocking: these rows cover the three package-field warnings. The generated-record warning (resolve-theme.mjs:114) and the no-theme-object warning (:91) also go through warnTheme, but nothing fails if either goes back to console.warn. A case whose generated record names an owner such as '@evil/\u001b]0;x\u0007\npkg' would lock the record path the changeset mentions.
User impact
Someone who runs
astryx componentin a checkout they do not control sees a theme warning when the configured theme does not load. That warning printed the checkout'sastryx.themevalue as written, so a value with a newline or a terminal escape sequence could add fake lines or rewrite the terminal. Now every theme warning prints as one inert line: control and format characters show as�.Problem and solution fit
The warning interpolates a value the checkout controls straight into terminal output. The fix replaces only the characters that a terminal acts on, so the warning keeps its meaning and stays readable.
Smallest restoration
resolve-theme.mjssends every theme warning through onewarnThemehelper that replaces Unicode control (Cc) and format (Cf) characters with U+FFFD. This covers theastryx.themefield and the generated theme record, which also comes from the checkout. What loads, and when, is unchanged.Expected behavior and authority
Consistency with
spec:AST-050FR3: theastryx.themefield keeps its released meaning, and only how a warning prints changes. No record change.Evidence
main,astryx.theme: "@evil/<ESC>]0;owned<BEL> pkg"prints the warning with the raw escape sequence and a line break.⚠ theme: could not resolve package "@evil/�]0;owned��pkg"on one line../legacy.cjsloads and warns exactly as before; the existing package-field and generated-record cases are unchanged.resolveTheme warningscases fail if a warning bypasseswarnTheme.Scope
Credit
This carries the warning hardening from #5525 by @bhamodi (co-author), which Robohands flagged in review on that PR. #5525 was closed as superseded by #6874 and AST-050 FR3; this is the part that still applies.
Testing
resolveTheme warningscases cover a file path, a scoped package and a bare name with escape sequences, a newline, a carriage return and a bidi override. Each prints one warning with no control or format characters.@evil/<ESC>]0;owned<BEL>\npkgprints as⚠ theme: could not resolve package "@evil/�]0;owned��pkg".