Skip to content

[BUG]: TestAccGithubMembership fails on GHES #3256

Closed

Description

@amreshh

Expected Behavior

Running the unit test make testacc T=TestAccGithubTeamMembership for github enterprise server should be successful.

Actual Behavior

make testacc T=TestAccGithubTeamMembership fails because it the api request is being sent to the web frontend instead of the api, which results in a redirect to the login page and a http/406 error.

The endpoint of our enterprise server is https://hostname/api/v3

(github hostname and username has been redacted), but from the test result we can see the wrong uri is being called.

❯ make testacc T=TestAccGithubTeamMembership

==> Running acceptance tests on branch: 🌿 bug/base-url-ghes 🌿...
TF_ACC=1 CGO_ENABLED=0 go test ./github/... -v -run '^TestAcc' -run='TestAccGithubTeamMembership'  -timeout 120m -count=1
=== RUN   TestAccGithubTeamMembership
=== RUN   TestAccGithubTeamMembership/creates_a_team_membership
    resource_github_team_membership_test.go:26: Step 1/2 error: Check failed: Check 1/4 error: GET https://_hostname_/login?return_to=https%3A%2F%2F_hostname_%2Forganizations%2F0%2Fteam%2F37%2Fmemberships%2F_username_: 406  []
    panic.go:694: Error running post-test destroy, there may be dangling resources: GET https://_hostname_/login?return_to=https%3A%2F%2F_hostname_%2Forganizations%2F0%2Fteam%2F37%2Fmemberships%2F_username_: 406  []
=== RUN   TestAccGithubTeamMembership/is_case_insensitive
    resource_github_team_membership_test.go:64: Step 1/2 error: Check failed: Check 1/1 error: GET https://_hostname_/login?return_to=https%3A%2F%2F_hostname_%2Forganizations%2F0%2Fteam%2F39%2Fmemberships%2F_username_: 406  []
    panic.go:694: Error running post-test destroy, there may be dangling resources: GET https://_hostname_/login?return_to=https%3A%2F%2F_hostname_%2Forganizations%2F0%2Fteam%2F39%2Fmemberships%2F_username_: 406  []
--- FAIL: TestAccGithubTeamMembership (23.31s)
    --- FAIL: TestAccGithubTeamMembership/creates_a_team_membership (11.85s)
    --- FAIL: TestAccGithubTeamMembership/is_case_insensitive (11.46s)
FAIL
FAIL    github.com/integrations/terraform-provider-github/v6/github     23.315s
FAIL
make: *** [GNUmakefile:62: testacc] Error 1

Terraform Version

N.A.

Affected Resource(s)

Testcases which call getTestMeta()

Terraform Configuration Files

Steps to Reproduce

Running below testcase against a GHES environment.

make testacc T=TestAccGithubTeamMembership

Debug Output

Panic Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    Type: Bug
    Status: Triage
    on Mar 5, 2026
  2. github-actions commented on Mar 5, 2026

    @github-actions

    👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

  3. deiga commented on Mar 5, 2026

    @deiga
    Collaborator

    Hey @amreshh
    Could you share the ENV variables you used to configure the test run?

  4. amreshh commented on Mar 5, 2026

    @amreshh
    Author

    Hey @deiga : these are the env var's I set

    GH_TEST_AUTH_MODE=enterprise
    GH_TEST_ORG_USER=<<my-test-user>>
    GITHUB_BASE_URL=https://<<my-github-enterprise-instance>>/
    GITHUB_ENTERPRISE_SLUG=<<my-enterprise>>
    GITHUB_OWNER=<<my-test-org>>
    GITHUB_TOKEN=<<root token>>
    GITHUB_USERNAME=root
  5. amreshh commented on Mar 5, 2026

    @amreshh
    Author

    I also tried setting GITHUB_BASE_URL to the api endpoint like so

    GITHUB_BASE_URL=https://<<my-github-enterprise-instance>>/api/v3/

    Then the test complains about the baseURL not having a trailing slash, eventhough I am setting it

    ❯ set -gx GITHUB_BASE_URL "https://<<my-github-enterprise-instance>>/api/v3/"
    
    ❯ make testacc T=TestAccGithubTeamMembership
    ==> Running acceptance tests on branch: 🌿 bug/base-url-ghes 🌿...
    TF_ACC=1 CGO_ENABLED=0 go test ./github/... -v -run '^TestAcc' -run='TestAccGithubTeamMembership'  -timeout 120m -count=1
    === RUN   TestAccGithubTeamMembership
    === RUN   TestAccGithubTeamMembership/creates_a_team_membership
        resource_github_team_membership_test.go:26: Step 1/2 error: Check failed: Check 1/4 error: baseURL must have a trailing slash, but "https://<<my-github-enterprise-instance>>/api/v3" does not
    --- FAIL: TestAccGithubTeamMembership (11.58s)
        --- FAIL: TestAccGithubTeamMembership/creates_a_team_membership (11.58s)
    panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x104df3d]
    
    goroutine 20 [running]:
    testing.tRunner.func1.2({0x1410000, 0x2388d00})
            /usr/lib/go/src/testing/testing.go:1974 +0x232
    testing.tRunner.func1()
            /usr/lib/go/src/testing/testing.go:1977 +0x349
    panic({0x1410000?, 0x2388d00?})
            /usr/lib/go/src/runtime/panic.go:860 +0x13a
    github.com/integrations/terraform-provider-github/v6/github.testAccCheckGithubTeamMembershipDestroy(0x3b269fd7c3f0)
            /home/hanoeman_a/projects/github.com/terraform-provider-github/github/resource_github_team_membership_test.go:117 +0x21d
    github.com/hashicorp/terraform-plugin-testing/helper/resource.runPostTestDestroy({0x1705a30, 0x3b269fc1c1e0}, {0x1713558, 0x3b269fdc26c8}, {0x0, 0x3b269fe3e380, {0x0, 0x0, 0x0}, 0x3b269fe36990, ...}, ...)
            /home/hanoeman_a/.go/mod/github.com/hashicorp/[email protected]/helper/resource/testing_new.go:41 +0x14c
    github.com/hashicorp/terraform-plugin-testing/helper/resource.runNewTest.func1()
            /home/hanoeman_a/.go/mod/github.com/hashicorp/[email protected]/helper/resource/testing_new.go:87 +0x3bb
    runtime.Goexit()
            /usr/lib/go/src/runtime/panic.go:694 +0x5e
    testing.(*common).FailNow(0x3b269fdc26c8)
            /usr/lib/go/src/testing/testing.go:1022 +0x4a
    testing.(*common).Fatalf(0x3b269fdc26c8, {0x1638048?, 0x16301e1?}, {0x3b269fae0c90?, 0x16318ee?, 0x10?})
            /usr/lib/go/src/testing/testing.go:1228 +0x59
    github.com/hashicorp/terraform-plugin-testing/helper/resource.runNewTest({0x1705a30, 0x3b269fc1c1e0}, {0x1713558, 0x3b269fdc26c8}, {0x0, 0x3b269fe3e380, {0x0, 0x0, 0x0}, 0x3b269fe36990, ...}, ...)
            /home/hanoeman_a/.go/mod/github.com/hashicorp/[email protected]/helper/resource/testing_new.go:430 +0x2b23
    github.com/hashicorp/terraform-plugin-testing/helper/resource.Test({0x1713558, 0x3b269fdc26c8}, {0x0, 0x3b269fe3e380, {0x0, 0x0, 0x0}, 0x3b269fe36990, 0x0, 0x0, ...})
            /home/hanoeman_a/.go/mod/github.com/hashicorp/[email protected]/helper/resource/testing.go:992 +0x6c5
    github.com/integrations/terraform-provider-github/v6/github.TestAccGithubTeamMembership.func1(0x3b269fdc26c8)
            /home/hanoeman_a/projects/github.com/terraform-provider-github/github/resource_github_team_membership_test.go:26 +0x8b8
    testing.tRunner(0x3b269fdc26c8, 0x16e7a18)
            /usr/lib/go/src/testing/testing.go:2036 +0xea
    created by testing.(*T).Run in goroutine 19
            /usr/lib/go/src/testing/testing.go:2101 +0x4c5
    FAIL    github.com/integrations/terraform-provider-github/v6/github     11.590s
    FAIL
    make: *** [GNUmakefile:62: testacc] Error 1
    
  6. amreshh commented on Mar 5, 2026

    @amreshh
    Author

    In provider.go, the baseURL uses getBaseURL() which parses the endpoint and also sets whether or not this is a GitHub Enterprise Server.

    But acc_test.go uses whatever is being set as the GITHUB_BASE_URL var, so we don't get the getBaseURL() parsing.

  7. deiga commented on Mar 5, 2026

    @deiga
    Collaborator

    Thanks for highlighting this!

    We don't currently have a GHES instance to test against, so this has fallen through the cracks.

    Would you be available to provide a PR to fix it?

  8. amreshh commented on Mar 5, 2026

    @amreshh
    Author

    Yes I was already working on a fix 😀

  9. removed
    Status: Triage
    on Jun 5, 2026
  10. added this to the v6.13.0 milestone on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions