Skip to content

Rewrite transferred action references to canonical repositories - #118

Open
nodeselector wants to merge 3 commits into
mainfrom
nodeselector-reject-transferred-actions
Open

Rewrite transferred action references to canonical repositories#118
nodeselector wants to merge 3 commits into
mainfrom
nodeselector-reject-transferred-actions

Conversation

@nodeselector

Copy link
Copy Markdown
Collaborator

What changed

  • Preserve GraphQL's canonical nameWithOwner when an action repository was renamed or transferred.
  • Rewrite writable workflow and local $/ action references from the old NWO to the canonical NWO, preserving subpaths and refs.
  • Emit canonical lockfile keys and repository metadata, including during --rescan.
  • Reject redirects found inside remote composites with a typed error naming the old NWO, canonical NWO, and upstream parent.

Why

The CLI previously discarded nameWithOwner, reported a successful lockfile, and left the runner unable to resolve the stale repository identity.

Testing

  • go test ./...
  • ruby test/integration/run.rb transferred_repository_rewritten
  • Fresh onboarding, --rescan, immediate --verify-local, local $/ rewrite planning, remote-composite rejection, and canonical dedup coverage

Fixes #110

Copilot AI balanced review requested due to automatic review settings August 31, 2026 19:19
@nodeselector
nodeselector requested a review from a team as a code owner August 31, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Mandatory rewrites can be silently skipped, and dependency filtering can invalidate transfer directness tracking.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 2 Medium severity

New issues introduced by this change (2)
Severity Finding
Medium severity internal/​pin/​plan.go — A transfer rewrite must not be best-effort. RewriteActionRefs skips anchored uses: scalars, and…
Medium severity internal/​pin/​plan.go — Rebuild the rewrite tracker after lookupIssues filter deps: filtering can shift indices, while…
What changed in this PR

Canonicalizes renamed or transferred action repositories across resolution, source rewriting, and lockfile generation.

Changes:

  • Preserves original and canonical repository identities during resolution.
  • Rewrites direct workflow and local-action references while rejecting remote-composite transfers.
  • Adds canonicalization and integration coverage.
File Description
test/​scenarios/​catalog.yml Adds a transfer rewrite scenario.
internal/​resolve/​discovery.go Tracks original refs and transfer errors.
internal/​pipeline/​diagnose.go Exposes live resolution details.
internal/​pipeline/​checks/​resolver.go Resolves original aliases from prewarmed data.
internal/​pipeline/​checks/​finding.go Extends workflow reports.
internal/​pin/​plan.go Plans canonical rewrites and transfer validation.
internal/​pin/​plan_test.go Tests transfer planning.
internal/​lockfile/​direct_tracker.go Recognizes transferred direct refs.
internal/​ghapi/​graphql_action_files.go Reads canonical GraphQL repository names.
internal/​ghapi/​graphql_action_files_test.go Tests GraphQL canonicalization.
internal/​dep/​dependency.go Stores and merges original refs.
internal/​dep/​dependency_test.go Tests transferred-source deduplication.
cmd/​gh-actions-lock/​command_test.go Tests CLI rewriting and rejection flows.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/pin/plan.go Outdated
Comment thread internal/pin/plan.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

REST-based resolution paths still lose canonical repository identity and can retain stale transferred references.

Review tier: Balanced
Findings: None

Issues resolved since last review (2)
Severity Finding
Medium severity internal/​pin/​plan.go — Rebuild the rewrite tracker after lookupIssues filter deps: filtering can shift indices, while… View resolved comment
Medium severity internal/​pin/​plan.go — A transfer rewrite must not be best-effort. RewriteActionRefs skips anchored uses: scalars, and… View resolved comment
Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

internal/ghapi/graphql_action_files.go:32

  • Transferred repositories are still missed whenever ResolveActionFiles uses its REST-only or anonymous fallback path. resolveAnonymous returns the requested Owner/Repo and never sets OriginalNWO, even though its HTTP client follows repository redirects, so the resolver creates no OriginalRefs; the workflow and lockfile therefore retain the stale NWO (and remote-composite redirects are not rejected). Capture the canonical repository from the REST response/final URL and populate these identity fields consistently for both resolution paths.
	Owner       string
	Repo        string
	OriginalNWO string

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.

gh actions-lock CLI and GitHub Actions Runner Disagree on Moved Repo Resolution

2 participants