fix: env file parser - #1444
Merged
Merged
Conversation
Signed-off-by: thunguo <tew@apache.org>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The multiline-quote handling is implemented in a focused way and is backed by both unit and CLI regression tests covering the reported failure mode.
Pull request overview
Fixes env-file parsing so --env-file can accept multiline single- and double-quoted values (e.g., readable multiline JSON), aligning CLI behavior with the use case in Issue #1443 while preserving the existing “shell-free” safety constraints.
Changes:
- Extend env assignment parsing to keep consuming physical lines until an opening quote is closed, preserving embedded newlines/indentation.
- Add unit coverage for multiline quoted parsing (single-quoted JSON and multiline double-quoted values with escaped quotes).
- Add CLI regression coverage verifying
powercontext config validate --env-fileaccepts multiline dashboard scopes JSON.
File summaries
| File | Description |
|---|---|
src/powercontext/cli/env_file.py |
Adds _split_assignment() to support multiline quoted assignments by consuming additional lines until quotes close. |
tests/test_env_file.py |
Adds parser regression tests for multiline single-quoted JSON and multiline double-quoted values. |
tests/test_config_cli.py |
Adds CLI regression test ensuring validate --env-file accepts multiline dashboard scopes JSON in managed blocks. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Teingi
reviewed
Sep 3, 2026
Member
|
ci failed |
Collaborator
Author
resolved |
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.
Which issue or RFC does this PR close?
Closes #1443.
Rationale for this change
PowerContext parsed environment files one physical line at a time. As a result, a quoted value that continued onto subsequent lines was rejected at its opening line with
No closing quotation, even when the quote was closed later in the file. This prevented readable multiline JSON values such asPOWERCONTEXT_SERVER_DASHBOARD_SCOPESfrom being used with--env-file.What changes are included in this PR?
powercontext config validate --env-fileaccepts multiline dashboard scope JSON.Are there any user-facing changes?
Yes. Commands that accept
--env-filenow support multiline quoted values. Existing single-line environment files continue to behave as before. There are no public API changes, persisted-format changes, breaking changes, or migration requirements.How was this change tested?
No closing quotationfailure before applying the fix.make check— passed, including lock-file validation, pre-commit hooks, Ruff, and type checking.uv run pytest tests/test_env_file.py tests/test_config_cli.py -q— 49 passed.uv run pytest tests/test_server.py tests/test_service_environment.py tests/test_service.py -q— 148 passed, 2 skipped.make test— 1,288 passed and 19 skipped. Threetests/client/test_receiver_service.pytests failed locally because they exercise Linux-only systemd service installation while the suite was run on macOS; these failures are unrelated to the environment-file parser change.AI usage statement