Skip to content

Fix acceptance test failures: git identity, headRepository JSON, obsolete traversal test#13037

Merged
williammartin merged 4 commits intotrunkfrom
kw/acceptance-test-git-config
Mar 26, 2026
Merged

Fix acceptance test failures: git identity, headRepository JSON, obsolete traversal test#13037
williammartin merged 4 commits intotrunkfrom
kw/acceptance-test-git-config

Conversation

@BagToad
Copy link
Member

@BagToad BagToad commented Mar 25, 2026

Description

Fixes several acceptance test failures found while running the suite locally. Each fix is in its own commit.

Fix 1: Git identity in testscript sandbox

The testscript sandbox overrides HOME, so git inside the sandbox can't find the user's global user.name/user.email. This causes "Author identity unknown" errors in any acceptance test that makes commits (e.g. extensions, PRs). The fix writes a minimal .gitconfig into the sandbox during sharedSetup.

Fix 2: Fetch nameWithOwner in headRepository GraphQL query

dd424d8 (agent-task listings) added NameWithOwner to the PRRepository struct but didn't update the headRepository GraphQL query to fetch it. Since export_pr.go dumps the raw struct, gh pr view --json headRepository started emitting "nameWithOwner":"" - breaking the pr-create-respects-simple-pushdefault acceptance test assertion.

The fix adds nameWithOwner to the GraphQL query so the field is actually populated, and updates the test assertion to expect it.

Fix 3: Remove run-download-traversal acceptance test

GitHub's Artifact API now rejects artifact names like .. server-side (400 Bad Request), making it impossible to create artifacts with path traversal names. The test scenario can no longer be reproduced through normal artifact creation. The client-side traversal check in gh run download remains as defense-in-depth.

Known failures not addressed

These were observed during the acceptance run but are not bugs in gh:

Test Failure Root cause
TestExtensions/extension Search doesn't find repo after 10s sleep GitHub search indexing latency on private repos - flaky timing
TestRepo/repo-list-rename HTTP 409 during deferred cleanup GitHub API race condition - repo operation still in progress at cleanup time. Test itself passes.
TestRepo/repo-archive-unarchive HTTP 409 during deferred cleanup Same as above. Test itself passes.
TestRulesets/ruleset HTTP 403 on gh ruleset check Requires GitHub Pro or public repos - plan limitation of the test org
TestSecrets/secret-org Workflow assertion step fails Secret value doesn't match in Actions runner - needs further investigation

Commits

  1. ed97fa9 - Set git identity in testscript sandbox so acceptance tests that make commits don't fail with "Author identity unknown"
  2. 0433096 - Fetch nameWithOwner in headRepository GraphQL query to fix regression from dd424d8 that broke pr-create-respects-simple-pushdefault
  3. 9fd5f06 - Remove run-download-traversal test since GitHub's Artifact API now prevents the scenario server-side

BagToad and others added 3 commits March 25, 2026 12:47
The sandbox overrides HOME so git cannot find the user's global config,
causing 'Author identity unknown' errors when acceptance test scripts
make commits. Write a minimal .gitconfig with user.name and user.email
into the sandbox working directory during sharedSetup.

Co-Authored-By: Copilot <[email protected]>
GitHub's Artifact API now rejects artifact names like '..' server-side
with a 400 Bad Request, making it impossible to create artifacts with
path traversal names. This means the scenario this test was verifying
(that gh run download catches traversal names) can no longer be
reproduced through normal artifact creation.

The client-side traversal check in gh run download remains in place as a
defense-in-depth measure.

Co-authored-by: Copilot <[email protected]>
Commit dd424d8 added NameWithOwner to PRRepository for agent-task
listings but didn't update the headRepository GraphQL query to fetch it.
This caused gh pr view --json headRepository to emit an empty
"nameWithOwner":"" field, breaking the pr-create-respects-simple-
pushdefault acceptance test.

Fetch nameWithOwner in the query and update the test assertion to expect
it.

Co-authored-by: Copilot <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes multiple acceptance test failures by ensuring git commits work inside the testscript sandbox, correcting a GraphQL selection regression for headRepository.nameWithOwner, and removing an acceptance test scenario that can no longer be reproduced due to upstream API validation.

Changes:

  • Write a minimal .gitconfig into the acceptance test sandbox so git commit doesn’t fail due to missing identity.
  • Fetch nameWithOwner for headRepository in the PR GraphQL fragment and update the affected acceptance assertion.
  • Remove the obsolete run-download-traversal acceptance test.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
acceptance/acceptance_test.go Sets up sandbox git identity via .gitconfig so commit-making scripts succeed.
api/query_builder.go Extends headRepository GraphQL fragment to include nameWithOwner.
acceptance/testdata/pr/pr-create-respects-simple-pushdefault.txtar Updates expected JSON output to include headRepository.nameWithOwner.
acceptance/testdata/workflow/run-download-traversal.txtar Removes an acceptance test that’s no longer viable due to server-side artifact name validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 17 to 20
"github.com/cli/cli/v2/internal/ghcmd"
"github.com/cli/go-internal/testscript"
"github.com/MakeNowJust/heredoc"
)
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

Import block isn’t gofmt-sorted (third-party imports should be lexicographically ordered). As-is, the gofmt formatter (enabled in golangci-lint) will report this file; please run gofmt/goimports to normalize the import order.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Well that's just not true. Our linter seems happy.

Comment on lines 389 to 391
case "headRepository":
q = append(q, `headRepository{id,name}`)
q = append(q, `headRepository{id,name,nameWithOwner}`)
case "assignees":
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

This change to the headRepository fragment isn’t currently covered by api/query_builder_test.go. Since there are already unit tests asserting the generated fragments for other fields, consider adding a case that asserts IssueGraphQL([]string{"headRepository"}) (or via PullRequestGraphQL) includes nameWithOwner to prevent regressions.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Not super concerned with this personally.

Copy link
Member

@williammartin williammartin left a comment

Choose a reason for hiding this comment

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

Fix 2 here looks like it breaks a lot of other tests, which are skipped by default right now:

 - pr-create-push-default-upstream-no-merge-ref-fork.txtar:50
 - pr-create-respects-push-destination.txtar:53
 - pr-create-remote-ref-with-branch-name-slash.txtar:46
 - pr-create-respects-remote-pushdefault.txtar:49
 - pr-create-guesses-remote-from-sha.txtar:48
 - pr-create-respects-user-colon-branch-syntax.txtar:47
 - pr-create-guesses-remote-from-sha-with-branch-name-slash.txtar:50
 - pr-create-respects-branch-pushremote.txtar:49

Or at least, maybe they were already broken? In any case, we should fix them.

@williammartin
Copy link
Member

I fixed these failures in 971be97

Copy link
Member

@williammartin williammartin left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@williammartin williammartin enabled auto-merge March 26, 2026 12:32
@williammartin williammartin merged commit 39407e6 into trunk Mar 26, 2026
11 checks passed
@williammartin williammartin deleted the kw/acceptance-test-git-config branch March 26, 2026 12:32
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.

3 participants