Skip to content

fix: env file parser - #1444

Merged
Teingi merged 3 commits into
oceanbase:masterfrom
thunguo:fix/env-file-parser
Sep 4, 2026
Merged

fix: env file parser#1444
Teingi merged 3 commits into
oceanbase:masterfrom
thunguo:fix/env-file-parser

Conversation

@thunguo

@thunguo thunguo commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

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 as POWERCONTEXT_SERVER_DASHBOARD_SCOPES from being used with --env-file.

What changes are included in this PR?

  • Continue consuming physical lines when a quoted environment value has not closed yet.
  • Preserve newlines and indentation inside multiline single-quoted and double-quoted values.
  • Keep the parser shell-free and retain its existing validation for shell expansion, invalid assignments, duplicate names, and NUL characters.
  • Add parser regression coverage for multiline JSON, double-quoted values, and assignments following a multiline value.
  • Add CLI regression coverage proving that powercontext config validate --env-file accepts multiline dashboard scope JSON.

Are there any user-facing changes?

Yes. Commands that accept --env-file now 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?

  • Reproduced the original No closing quotation failure 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. Three tests/client/test_receiver_service.py tests 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

Signed-off-by: thunguo <tew@apache.org>
Copilot AI lite review requested due to automatic review settings September 3, 2026 11:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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-file accepts 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.

Comment thread src/powercontext/cli/env_file.py Outdated
@Teingi

Teingi commented Sep 4, 2026

Copy link
Copy Markdown
Member

ci failed

@thunguo

thunguo commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

ci failed

resolved

@thunguo
thunguo requested a review from Teingi September 4, 2026 09:08

@Teingi Teingi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Teingi
Teingi merged commit 9757a99 into oceanbase:master Sep 4, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Environment file parser does not support multiline quoted values

3 participants