Skip to content

Conversation

@iblankJC
Copy link

Resolves #2836


Before the change?

  • Fails to read files larger than 1MB with error: unsupported content encoding: none

After the change?

  • Checks GitHub content encoding and uses appropriate Accept header
  • Supports reading repository files larger than 1MB

Pull request checklist

  • Schema migrations have been created if needed (not needed)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions
Copy link

👋 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! 🚀

@iblankJC iblankJC force-pushed the support-larger-files branch from 3631fd8 to b9e52ac Compare December 24, 2025 18:20
@deiga
Copy link
Collaborator

deiga commented Dec 24, 2025

Hey @iblankJC 👋

Thank you for your contribution! It seems that this use-case has already been covered in the SDK. Could you change your approach to use the SDK DownloadContents method instead? https://github.com/google/go-github/blob/v67.0.0/github/repos_contents.go#L139

Copy link
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

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

It seems that this use-case has already been covered in the SDK. Could you change your approach to use the SDK DownloadContents method instead? https://github.com/google/go-github/blob/v67.0.0/github/repos_contents.go#L139

@iblankJC iblankJC force-pushed the support-larger-files branch from 8f6a30b to e1a50a0 Compare January 13, 2026 01:48

var content string

if encoding == "" || encoding == "none" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: Can you link to documentation where it states that this is the best way to determine if DownloadContents should be used?
I would've thought that using fc.Size could have been a better indicator

Comment on lines +411 to +438
testCase := func(t *testing.T, mode string) {
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessMode(t, mode) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: initialConfig,
Check: initialCheck,
},
{
Config: updatedConfig,
Check: updatedCheck,
},
},
})
}

t.Run("with an anonymous account", func(t *testing.T) {
t.Skip("anonymous account not supported for this operation")
})

t.Run("with an individual account", func(t *testing.T) {
testCase(t, individual)
})

t.Run("with an organization account", func(t *testing.T) {
testCase(t, organization)
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

We no longer use the testCase structure

Suggested change
testCase := func(t *testing.T, mode string) {
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessMode(t, mode) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: initialConfig,
Check: initialCheck,
},
{
Config: updatedConfig,
Check: updatedCheck,
},
},
})
}
t.Run("with an anonymous account", func(t *testing.T) {
t.Skip("anonymous account not supported for this operation")
})
t.Run("with an individual account", func(t *testing.T) {
testCase(t, individual)
})
t.Run("with an organization account", func(t *testing.T) {
testCase(t, organization)
})
resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnauthenticated(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: initialConfig,
Check: initialCheck,
},
{
Config: updatedConfig,
Check: updatedCheck,
},
},
})

}
`, randomID, initialContent)

updatedConfig := fmt.Sprintf(`
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: If this is equal to the string in initialConfig save for the updatedContent then it could make sense to reduce duplication here and extract the template string and reuse it

Comment on lines +381 to +398
initialCheck := resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"github_repository_file.test", "content",
initialContent,
),
resource.TestCheckResourceAttrSet(
"github_repository_file.test", "sha",
),
resource.TestCheckResourceAttrSet(
"github_repository_file.test", "commit_sha",
),
resource.TestCheckResourceAttr(
"github_repository_file.test", "file",
"large-file.txt",
),
)

updatedCheck := resource.ComposeTestCheckFunc(
Copy link
Collaborator

Choose a reason for hiding this comment

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

issue: Please inline these, using variables is unnecessary obfuscation

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.

[BUG]: increase file size limit github_repository_file above 1mb

2 participants