Skip to content

Commit ea1f4ea

Browse files
pditommasoclaude
andcommitted
Fix HttpPluginRepository empty plugin list check (#6650)
Revert condition from `!decoded.plugins` to `decoded.plugins == null` to avoid throwing an exception when the registry returns an empty list. In Groovy, an empty list is falsy, so the previous check incorrectly treated a valid empty response as a parse failure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
1 parent 17a6075 commit ea1f4ea

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

modules/nf-commons/src/main/nextflow/plugin/HttpPluginRepository.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class HttpPluginRepository implements PrefetchUpdateRepository {
168168
}
169169
try {
170170
final ListDependenciesResponse decoded = encoder.decode(body)
171-
if( !decoded.plugins ) {
171+
if( decoded.plugins == null ) {
172172
throw new PluginRuntimeException("Failed to download plugin metadata: Failed to parse response body")
173173
}
174174
final result = new HashMap<String, PluginInfo>()

modules/nf-commons/src/test/nextflow/plugin/HttpPluginRepositoryTest.groovy

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,26 +160,19 @@ class HttpPluginRepositoryTest extends Specification {
160160

161161
// ------------------------------------------------------------------------
162162

163-
def 'handle prefetch error when metadata service sends back incorrectly formatted response'() {
163+
def 'handle prefetch when registry returns empty plugins list'() {
164164
given:
165165
wiremock.stubFor(get(urlEqualTo("/v1/plugins/dependencies?plugins=nf-fake&nextflowVersion=${BuildInfo.version}"))
166166
.willReturn(aResponse()
167167
.withStatus(200)
168-
.withBody("""{
169-
"not-plugins": [
170-
{
171-
"id": "nf-fake"
172-
}
173-
]
174-
}
175-
""")))
168+
.withBody('{"plugins": []}')))
176169

177170
when:
178171
unit.prefetch([new PluginRef("nf-fake")])
179172

180173
then:
181-
def err = thrown PluginRuntimeException
182-
err.message.startsWith("Unexpected error while fetching plugin metadata from: http://localhost")
174+
noExceptionThrown()
175+
unit.getPlugins() == [:]
183176
}
184177

185178
// ------------------------------------------------------------------------

0 commit comments

Comments
 (0)