fix(npm): escape backslash line continuation in tar command - #1663
Open
lengau wants to merge 1 commit into
Open
Conversation
lengau
marked this pull request as draft
August 12, 2026 18:02
lengau
marked this pull request as ready for review
August 12, 2026 18:20
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes the npm plugin’s generated tar shell command so it emits a real bash line-continuation (\ + newline) instead of having Python treat \<newline> as a string-continuation escape inside the f-string, which previously collapsed the command onto one line with unintended whitespace.
Changes:
- Escapes the end-of-line backslash in the
tarcommand template incraft_parts/plugins/npm_plugin.pyso the generated script contains a literal\followed by a newline. - Updates the unit test assertion in
tests/unit/plugins/test_npm_plugin.pyto match the corrected multi-line command output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
craft_parts/plugins/npm_plugin.py |
Fixes the f-string so the emitted tar command uses a proper bash line continuation. |
tests/unit/plugins/test_npm_plugin.py |
Adjusts expected build-command output to assert the literal \ + newline behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
bepri
approved these changes
Aug 12, 2026
mr-cal
force-pushed
the
work/fix-npm-plugin-backslash-escape
branch
from
August 12, 2026 19:44
59c9676 to
f0b9935
Compare
mr-cal
approved these changes
Aug 13, 2026
lengau
force-pushed
the
work/fix-npm-plugin-backslash-escape
branch
from
August 13, 2026 16:27
f0b9935 to
3a799d2
Compare
The unescaped backslash in the f-string was interpreted by Python as a string continuation, silently joining the tar and --no-same-owner lines with leftover indentation whitespace instead of emitting a real shell line continuation. Escape it so the generated script contains a literal backslash-newline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
lengau
force-pushed
the
work/fix-npm-plugin-backslash-escape
branch
from
August 14, 2026 14:13
3a799d2 to
61062d6
Compare
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.
Stacked on #1662.
Addresses review comment: #1662 (comment)
The f-string generating the
tarshell command innpm_plugin.pyhad an unescaped\at end-of-line. Since it's not a raw string, Python treated\<newline>as a string-continuation escape, silently swallowing the newline and merging thetar ...and--no-same-owner ...lines with leftover indentation whitespace baked in as literal spaces, instead of emitting a real shell line-continuation.Escaped it as
\\so the generated script contains an actual\followed by a newline (valid bash line continuation), and updated the corresponding test assertion.Verified with
ruff checkandpytest tests/unit/plugins/test_npm_plugin.py(34 passed).