Skip to content

readBytes does not support non-text files for non-Github providers #6208

Open
@swingingsimian

Description

@swingingsimian

Bug report

RepositoryProvider.readBytes does not work for non-github providers and non-text files. Verified with Gitea and Bitbucket, but I suspect other providers are also affected.

Expected behavior and actual behavior

I expect that the bytes are returned for the content specified by the given url. But it appears that the content is corrupted when reading and decoding the response.

def 'should read bytes gitea content'() {

        given:
        final String FREE_TIER_CONFIG = '''
        providers {

            mygitea {
                server = 'https://gitea.com'
                endpoint = 'https://gitea.com/api/v1'
                platform = 'gitea'
            }

        }
        '''
        def config = new ProviderConfig('gitea', new ConfigSlurper().parse(FREE_TIER_CONFIG).providers.mygitea as ConfigObject)
        def repo = new GiteaRepositoryProvider('swingingsimiangitea/rnaseq', config)

        when:
        def result = repo.readBytes('/docs/images/nf-core-rnaseq_logo_dark.png')

        then:
        result.size() == 26500
    }

    def 'should read bytes github content'() {

        given:
        def repo = new GithubRepositoryProvider('swingingsimian/rnaseq')

        when:
        def result = repo.readBytes('/docs/images/nf-core-rnaseq_logo_dark.png')
        then:
        result.size() == 26500 // Actual size of the content
    }

These tests can be found here: https://github.com/swingingsimian/nextflow/blob/readBytes-corrupts-response/modules/nextflow/src/test/groovy/nextflow/scm/GiteaRepositoryProviderTest.groovy

Steps to reproduce the problem

See above.

Program output

Gitea test fails, github test passed.

Environment

  • Nextflow version: 25.05.0-edge
  • Java version: [Corretto-17.0.13.11.1]
  • Operating system: macOS
  • Bash version: zsh 5.9 (arm64-apple-darwin24.0)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions