From 98d7c3769abf98182724be4fffd4490483b24fc6 Mon Sep 17 00:00:00 2001 From: "slominskir-coding-agent[bot]" <335168828+slominskir-coding-agent[bot]@users.noreply.github.com> Date: Thu, 1 Oct 2026 13:44:54 -0400 Subject: [PATCH] Reject a deploy request without a version A request without the ver parameter passed a null version to validateSemver, where Pattern.matcher(null) threw a NullPointerException. The deploy servlet then failed with an error page instead of its JSON response. Treat a missing version like any other non-semver version, so the caller gets "Version string must be semver formatted". Co-Authored-By: Claude Opus 5.5 --- .../java/org/jlab/adm/business/session/DeployerFacade.java | 2 +- .../org/jlab/adm/business/session/DeployerFacadeTest.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jlab/adm/business/session/DeployerFacade.java b/src/main/java/org/jlab/adm/business/session/DeployerFacade.java index c9ec81f..7d35526 100644 --- a/src/main/java/org/jlab/adm/business/session/DeployerFacade.java +++ b/src/main/java/org/jlab/adm/business/session/DeployerFacade.java @@ -63,7 +63,7 @@ private void validateSemver(String ver) throws UserFriendlyException { "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"; final Pattern p = Pattern.compile(regex); - if (!p.matcher(ver).matches()) { + if (ver == null || !p.matcher(ver).matches()) { throw new UserFriendlyException("Version string must be semver formatted"); } } diff --git a/src/test/java/org/jlab/adm/business/session/DeployerFacadeTest.java b/src/test/java/org/jlab/adm/business/session/DeployerFacadeTest.java index 0f70135..bbdb85f 100644 --- a/src/test/java/org/jlab/adm/business/session/DeployerFacadeTest.java +++ b/src/test/java/org/jlab/adm/business/session/DeployerFacadeTest.java @@ -16,6 +16,7 @@ import org.jlab.smoothness.business.exception.UserFriendlyException; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.NullSource; import org.junit.jupiter.params.provider.ValueSource; class DeployerFacadeTest { @@ -87,8 +88,10 @@ void semverIsAccepted(String version) throws Exception { assertEquals(version, started.get(0).getVersion()); } - // The version is appended to the deploy command run in a shell, so anything else is rejected + // The version is appended to the deploy command run in a shell, so anything else is rejected. + // Null is a request without the ver parameter. @ParameterizedTest + @NullSource @ValueSource( strings = { "",