Repository navigation
fix(#8604): env-data loader backtick resync and NUL export state - #8937
fullsend-ai-coder[bot] wants to merge 2 commits into
Conversation
Two parser fidelity follow-ups from the #8591 review in the .env data loader (internal/runtime/env_data.go): - skip_statement() tracked quotes and ${...}/$(...) but not backticks, so a rejected statement with a backtick command substitution spanning lines resynced inside it and read its inner lines as statements. Backticks now open a span (unquoted, inside double quotes or inside $(...)) that only an unescaped backtick closes; an unterminated span still falls back to the line end. - statement() marked a name exported after assign() whether or not assign() accepted the value, so `A=private` then `export A='x<NUL>y'` kept `private` but exported it. assign() now reports acceptance and the export is recorded only on success. A name whose last assignment was dropped for a NUL byte is also not exported by a later bare `export NAME`; a later accepted assignment clears that state. Adds a test for each, and regenerates the codex launch golden files, which embed the loader script. Note: pre-commit could not fetch its remote hook repos (TLS failure in the sandbox); go-fmt, go-vet, whitespace, EOF and line-ending checks were run directly and passed. golangci-lint is not installed. Closes #8604
|
🤖 Finished Review · ✅ Success · Started 12:09 PM UTC · Completed 12:16 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.54 |
|
<!-- fullsend:risk-assessment --> DetailsModerate risk for a tightly scoped runtime loader bug fix with full issue alignment and test coverage, elevated from low by high recent commit churn in runtime files and lack of a feature flag rollback mechanism. Previous run<!-- fullsend:risk-assessment --> DetailsModerate risk for a tightly scoped runtime loader bug fix with full issue alignment and test coverage, elevated from low by high recent commit churn in runtime files and lack of a feature flag rollback mechanism. |
ReviewFindingsLow
Earlier findings
Previous run<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6ImVkZ2UtY2FzZSIsImZpbGUiOiJpbnRlcm5hbC9ydW50aW1lL2Vudl9kYXRhLmdvIiwiaWQiOiJmXzViNTI0ZWY1ZTVjZGM1NTIiLCJsaW5lIjozNjUsImFjdGlvbmFibGUiOnRydWV9XX0= --> ReviewFindingsLow
Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 12:18 PM UTC · Completed 12:24 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.27 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
skip_statement() did not recognize # comments while inside $(...), so a lone backtick (or quote) in such a comment opened a span that never closed and the resync fell back to the first newline, importing lines from the rejected statement. A word-start # inside $(...) now skips to the newline without altering the span stack. Adds a regression test and regenerates the codex launch golden files that embed the loader script. Note: pre-commit could not fetch its remote hook repos (TLS failure in the sandbox); gofmt and go vet were run directly and passed. golangci-lint is not installed. Addresses #8937 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
🔧 Fix agent — iteration 1 (bot-triggered)Addressed the single low-severity finding: comments inside rejected $(...) statements are now skipped in the env-data loader resync, with a regression test (verified failing before the fix) and regenerated golden files. Fixed (1):
Tests: passed CI inspections (5):
Conflict update: skipped; strategy
|
|
🤖 Finished Review · ✅ Success · Started 12:25 PM UTC · Completed 12:31 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.90 |
Superseded by updated review
| elif top == "\x60": | ||
| if c == "\x60": | ||
| stack.pop() | ||
| elif top == ")" and c == "#" and s[i - 1] in " \t\n;&|()": |
There was a problem hiding this comment.
[low] edge-case
The new comment branch in skip_statement treats an escaped space before # as a token boundary, so a literal escaped-space-then-# inside a rejected $(...) swallows the closing paren and resyncs at the first line end, importing INSIDE=1 from inside the rejected substitution. Narrow regression of the new branch.
Suggested fix: Track whether whitespace actually establishes a shell token boundary rather than inspecting only the preceding character; add a regression test with an escaped space before a literal # and the closing paren.
Summary
Fixes two parser fidelity bugs in the
.envdata loader (internal/runtime/env_data.go), both follow-ups from the #8591 review. When a statement is rejected, the parser now skips a backtick span that runs across lines as one unit. A value dropped for a NUL byte no longer leaves its name marked for export.Related Issue
#8604 (follow-up tracker: #8575)
Changes
skip_statement()now handles backticks. A backtick opens a span, whether it appears unquoted, inside double quotes or inside$(...), and only an unescaped backtick closes it. Quotes inside the span do not open a value. An unterminated span still falls back to the line end, the same as other quotes.assign()now reports whether it accepted the value, andstatement()marks the name exported only when it did. Before this fix,A=privatefollowed byexport A='x<NUL>y'keptprivatebut exported it.export NAMEalso skips a name whose last assignment was dropped for a NUL byte.testdata/codex/golden/*.txt), which embed the loader script. The diff there is only the script change.Testing
TestEnvDataLoad_NulValueKeepsExportState: an earlier value stays a non-exported shell variable after a dropped NUL value, including through a later bareexport. A later accepted value is exported as usual.TestEnvDataLoad_RejectedBacktickStatementSkippedWhole: covers multi-line backticks unquoted, inside double quotes and with an escaped backtick, plus the fallback for an unterminated backtick.go test ./internal/runtime/...passes.make lint: could not run, becausepre-commitcould not fetch its remote hook repos (TLS failure in the sandbox). I ran gofmt,go vet ./...and the whitespace, end-of-file and line-ending checks directly, and they passed.golangci-lintis not installed in the sandbox.go test ./internal/cli/...has failures that also occur onmainin this sandbox: the fetchserver tests can't dial out, andTestPostScriptEnv_*fails becauseFULLSEND_OUTPUT_SCHEMAis set in the environment. They are unrelated to this change.Checklist
!for breaking changes)🤖 Generated with Claude Code
Closes #8604
Post-script verification
agent/8604-env-loader-parser-fidelity)8b8c75bf5d3ffa22c3b20ff7d96be17835c0688a..HEAD)