Preserve && in AWF config JSON embedded in lock workflows#30700
Preserve && in AWF config JSON embedded in lock workflows#30700
&& in AWF config JSON embedded in lock workflows#30700Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/3447ba8a-5891-40c4-8805-4690ca448cc6 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
&& in AWF config printf&& in AWF config JSON embedded in lock workflows
There was a problem hiding this comment.
Pull request overview
Fixes GitHub Actions workflow parse failures by preventing Go’s JSON serialization from HTML-escaping & (e.g., turning && into \u0026\u0026) when embedding AWF config JSON into compiled lock workflows.
Changes:
- Emit AWF config JSON via
json.EncoderwithSetEscapeHTML(false)and trim the encoder’s trailing newline. - Add a regression test ensuring
&&is preserved (and\u0026is not present) inallowDomainspayloads.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/awf_config.go | Switch JSON emission to a non-HTML-escaping encoder to preserve GitHub Actions expressions (e.g., &&) in embedded config JSON. |
| pkg/workflow/awf_config_test.go | Add regression test asserting && remains intact and \u0026 does not appear in generated config JSON. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| var jsonBuffer bytes.Buffer | ||
| encoder := json.NewEncoder(&jsonBuffer) | ||
| encoder.SetEscapeHTML(false) | ||
| if err := encoder.Encode(awfConfig); err != nil { | ||
| return "", fmt.Errorf("failed to marshal AWF config to JSON: %w", err) | ||
| } | ||
|
|
||
| jsonBytes := bytes.TrimSuffix(jsonBuffer.Bytes(), []byte("\n")) | ||
| jsonStr := string(jsonBytes) |
|
@copilot review all comments and add tests to ensure the encoding is correct. |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/269b1c4e-fe0f-4595-8819-93ffd1ffa73b Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added follow-up test coverage in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot review all comments |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5ca46a8d-faca-418c-b766-7c5fd1510d19 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Reviewed all comments and addressed the remaining review item by extracting a shared JSON helper ( Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot precompile. |
Ran precompile with Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
AWF config JSON is embedded into compiled lock workflows via
printf. Go’s default JSON HTML escaping converted&to\u0026, which corrupted GitHub Actions expressions inside${{ ... }}(notably&&) and caused workflow parse failures.Serialization fix (AWF config generation)
json.Marshaltojson.EncoderwithSetEscapeHTML(false)inBuildAWFConfigJSON.Regression coverage
pkg/workflow/awf_config_test.goasserting expression operators are preserved inallowDomains.&&and does not contain\u0026.BuildAWFCommandto ensure the generated command payload preserves the full${{ ... }}expression content, keeps&&intact, and does not emit\u0026.Resulting behavior
${{ ... && ... }}now remains intact in the generated AWF config payload written into.lock.yml, allowing Actions expression parsing to proceed normally.