Skip to content

AzureRepositoryProvider readBytes corrupt #6286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,35 @@ final class AzureRepositoryProvider extends RepositoryProvider {
"${config.server}/${urlPath}"
}

/** {@inheritDoc} */
@Override
byte[] readBytes(String path) {
String readText( String path ) {
final url = getContentUrl(path)
final response = invokeAndParseResponse(url)
return response.get('content')?.toString()?.getBytes()
return response.get('content')?.toString()
}

/** {@inheritDoc} */
@Override
byte[] readBytes(String path) {
// For binary content, use direct download instead of JSON embedding
final queryParams = [
'download': true,
'includeContent': false,
'includeContentMetadata': false,
"api-version": 6.0,
'path': path
] as Map<String,Object>

if( revision ) {
queryParams['versionDescriptor.version'] = revision
if( COMMIT_REGEX.matcher(revision).matches() )
queryParams['versionDescriptor.versionType'] = 'commit'
}

final queryString = queryParams.collect({ "$it.key=$it.value"}).join('&')
final url = "$endpointUrl/items?$queryString"
// Use invokeBytes for direct binary content download
return invokeBytes(url)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import nextflow.extension.FilesEx
import nextflow.plugin.Plugins
import nextflow.secret.SecretsLoader
import spock.lang.IgnoreIf
import spock.lang.Requires
import spock.lang.Specification
/**
*
Expand Down Expand Up @@ -384,10 +385,12 @@ class CmdConfigTest extends Specification {

}


@IgnoreIf({System.getenv('NXF_SMOKE')})
@Requires({System.getenv('NXF_GITHUB_ACCESS_TOKEN')})
def 'should resolve remote config' () {
given:
SysEnv.push(GITHUB_TOKEN: System.getenv('NXF_GITHUB_ACCESS_TOKEN'))
and:
def buffer = new ByteArrayOutputStream()
def cmd = new CmdConfig(
args: ['https://github.com/nextflow-io/hello'],
Expand All @@ -404,6 +407,9 @@ class CmdConfigTest extends Specification {
}
'''
.stripIndent()

cleanup:
SysEnv.pop()
}

@IgnoreIf({System.getenv('NXF_SMOKE')})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ class AzureRepositoryProviderTest extends Specification {
result == 'println "Hello from Azure repos!"'
}

@IgnoreIf({System.getenv('NXF_SMOKE')})
@Requires({System.getenv('NXF_AZURE_REPOS_TOKEN')})
def 'should read bytes file content'() {
given:
def token = System.getenv('NXF_AZURE_REPOS_TOKEN')
def config = new ProviderConfig('azurerepos').setAuth(token)

when:
// uses repo at https://pditommaso.visualstudio.com/nf-azure-repo/_git/nf-azure-repo
def repo = new AzureRepositoryProvider('pditommaso/nf-azure-repo', config)
def result = repo.readBytes('/docs/images/nf-core-rnaseq_logo_light.png')

then:
result.length == 22915
result.sha256() == '7a396344498750f614155f6e4f38b7d6ca98ced45daf0921b64acf73b18efaf4'
}


@IgnoreIf({System.getenv('NXF_SMOKE')})
@Requires({System.getenv('NXF_AZURE_REPOS_TOKEN')})
def 'should fetch repo tags'() {
Expand Down Expand Up @@ -170,7 +188,7 @@ class AzureRepositoryProviderTest extends Specification {
result == [
new RepositoryProvider.BranchInfo('dev', 'cc0ca18640a5c995231e22d91f1527d5155d024b'),
new RepositoryProvider.BranchInfo('feature-x', '13456a001ba5a27d643755614ab8e814d94ef888'),
new RepositoryProvider.BranchInfo('master', 'f84130388714582e20f0e2ff9a44b41978ec8929'),
new RepositoryProvider.BranchInfo('master', 'a207636e419f18c4b8c8586b00e329ab4788a7f5'),
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,19 @@ class GiteaRepositoryProviderTest extends Specification {
result == DATA
}

@IgnoreIf({System.getenv('NXF_SMOKE')})
@Requires({System.getenv('NXF_GITEA_ACCESS_TOKEN')})
def 'should read bytes file content'() {
given:
def token = System.getenv('NXF_GITEA_ACCESS_TOKEN')
def config = new ProviderConfig('gitea', new ConfigSlurper().parse(CONFIG).providers.mygitea as ConfigObject).setAuth(token)

when:
def repo = new GiteaRepositoryProvider('pditommaso/test-hello', config)
def result = repo.readBytes('docs/images/nf-core-rnaseq_logo_light.png')

then:
result.length == 22915
result.sha256() == '7a396344498750f614155f6e4f38b7d6ca98ced45daf0921b64acf73b18efaf4'
}
}