Skip to content

Commit 59c4f4e

Browse files
pditommasoclaudebentsherman
authored
Fix String.format error when plugin URL contains percent chars (#6651)
Signed-off-by: Paolo Di Tommaso <[email protected]> Co-authored-by: Claude Opus 4.5 <[email protected]> Co-authored-by: Ben Sherman <[email protected]>
1 parent ae0e844 commit 59c4f4e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
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
@@ -137,7 +137,7 @@ class HttpPluginRepository implements PrefetchUpdateRepository {
137137
throw e
138138
}
139139
catch (Exception e) {
140-
throw new PluginRuntimeException(e, "Unable to connect to ${uri} - cause: ${e.message}")
140+
throw new PluginRuntimeException(e, "Unable to connect to %s - cause: %s", uri, e.message)
141141
}
142142
}
143143

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ class HttpPluginRepositoryTest extends Specification {
104104

105105
// ------------------------------------------------------------------------
106106

107+
def 'handle prefetch error with percent chars in error message'() {
108+
given:
109+
// Test that URLs containing '%' characters (like URL-encoded values) are handled
110+
// correctly when an exception occurs. The '%' must be escaped to '%%' to avoid
111+
// String.format interpretation in PluginRuntimeException.
112+
def repoWithEncodedUrl = new HttpPluginRepository("test-repo", new URI("http://localhost:${wiremock.port()}/path%20with%20spaces/"))
113+
wiremock.stop()
114+
115+
when:
116+
repoWithEncodedUrl.prefetch([new PluginRef("nf-fake")])
117+
118+
then:
119+
def err = thrown PluginRuntimeException
120+
// Verify the error message is properly formatted and contains the URL with encoded spaces
121+
err.message.contains("Unable to connect to")
122+
err.message.contains("path%20with%20spaces")
123+
}
124+
125+
// ------------------------------------------------------------------------
126+
107127
def 'handle prefetch error when metadata service returns an error response'() {
108128
given:
109129
wiremock.stubFor(get(urlEqualTo("/v1/plugins/dependencies?plugins=nf-fake&nextflowVersion=${BuildInfo.version}"))

0 commit comments

Comments
 (0)