fix: support network.allowed-domains as alias for network.allowed#48522
Conversation
- Support `network.allowed-domains` as a silent alias for `network.allowed` in `extractNetworkPermissions`, unioning both lists when both are present - Add `allowed-domains` as a deprecated valid field in the network object JSON schema so it does not fail strict schema validation - Add `getNetworkAllowedDomainsCodemod` codemod to rename `network.allowed-domains` → `network.allowed` (merging with any existing `network.allowed` entries) - Register the codemod in `GetAllCodemods` and update `expectedCodemodOrder` test - Update `.github/aw/network.md` to document the common naming confusion and show the correct `network.allowed` syntax Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds deprecated network.allowed-domains compatibility and automatic migration to network.allowed.
Changes:
- Accepts and compiles the deprecated alias.
- Adds a
gh aw fixcodemod with tests. - Documents the naming mistake and migration.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/frontmatter_extraction_security.go |
Unions canonical and deprecated domain lists. |
pkg/parser/schemas/main_workflow_schema.json |
Adds the deprecated schema alias. |
pkg/cli/fix_codemods.go |
Registers the codemod. |
pkg/cli/fix_codemods_test.go |
Updates expected codemod ordering. |
pkg/cli/codemod_network_allowed_domains.go |
Implements migration and merging. |
pkg/cli/codemod_network_allowed_domains_test.go |
Tests common migration scenarios. |
.github/workflows/smoke-copilot-auto.lock.yml |
Removes generated model-cost metadata. |
.github/aw/network.md |
Documents canonical naming and automatic fixing. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (2)
pkg/cli/codemod_network_allowed_domains.go:83
- For an alias-only flow-style value such as
allowed-domains: [defaults, github], this replaces the entire line withallowed:and silently deletes the domains. Rename only the key so the existing value, indentation, anchor, and trailing comment are preserved; the existingfindAndReplaceInLinehelper already provides that behavior.
result[absADStart] = fieldIndent + "allowed:"
pkg/cli/codemod_network_allowed_domains.go:76
- The merge path only recognizes block-list lines beginning with
-. Both properties are schema-valid as flow arrays, soallowed: [defaults]plusallowed-domains: [github]produces an empty merged list andgh aw fix --writedeletes both domains. Merge from the already parsednetworkMapslices (or a YAML node representation) rather than reparsing YAML text withcollectListItems.
// Collect domain items from allowed-domains
adDomains := collectListItems(networkLines[adStart : adEnd+1])
- Files reviewed: 8/8 changed files
- Comments generated: 3
- Review effort level: Medium
| ID: "network-allowed-domains-rename", | ||
| Name: "Rename network.allowed-domains to network.allowed", | ||
| Description: "Renames the deprecated 'network.allowed-domains' key to 'network.allowed', merging with any existing 'network.allowed' entries.", | ||
| IntroducedIn: "0.1.0", |
| The top-level `network` block uses **`allowed`** — not `allowed-domains`: | ||
|
|
||
| ```yaml | ||
| # WRONG — network.allowed-domains does not exist |
| for _, key := range []string{"allowed", "allowed-domains"} { | ||
| if raw, exists := networkObj[key]; exists { | ||
| if slice, ok := raw.([]any); ok { | ||
| for _, domain := range slice { | ||
| if domainStr, ok := domain.(string); ok { |
|
Excellent work! 🎉 This PR handles a common user mistake gracefully:
This is well-thought-out, focused, and ready to merge. Great contribution to improving the user experience! 👍
|
PR Triage
Fixes a common user footgun (
|
Users commonly write
network.allowed-domainsby analogy withsafe-outputs.allowed-domains, causing a compile-timeadditionalPropertiesschema error. This PR makes the compiler tolerate the wrong key and auto-migrates it.Changes
frontmatter_extraction_security.go):extractNetworkPermissionsunions bothallowedandallowed-domainswhen present, so affected workflows compile without error.main_workflow_schema.json): Addsallowed-domainsas a deprecated valid property in thenetworkobject, preventing immediate schema rejection.codemod_network_allowed_domains.go):gh aw fixnow renamesnetwork.allowed-domains→network.allowed, merging and deduplicating domain lists..github/aw/network.md): Adds a "Common Naming Mistake" section with a before/after example.