From 3bdca2e9107612ee840f895cf09475f1367fe938 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 26 Mar 2026 18:11:46 +0100 Subject: [PATCH 1/3] MD post check param loosen MDs immutable check --- .../src/main/java/org/folio/okapi/managers/ModuleManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/okapi-core/src/main/java/org/folio/okapi/managers/ModuleManager.java b/okapi-core/src/main/java/org/folio/okapi/managers/ModuleManager.java index 757e6243c..31bd0050c 100644 --- a/okapi-core/src/main/java/org/folio/okapi/managers/ModuleManager.java +++ b/okapi-core/src/main/java/org/folio/okapi/managers/ModuleManager.java @@ -110,7 +110,7 @@ public Future createList(List list, boolean check, ModuleDescriptor exMd = tempList.get(id); String exJson = Json.encodePrettily(exMd); String json = Json.encodePrettily(md); - if (!json.equals(exJson)) { + if (check && !json.equals(exJson)) { return Future.failedFuture(new OkapiError(ErrorType.USER, messages.getMessage("10203", id))); } From 07e7f175c2282151ec49b34dd70fa9b81cf60cd2 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 27 Mar 2026 11:52:35 +0100 Subject: [PATCH 2/3] Document check=false behavior --- doc/guide.md | 5 +++++ .../java/org/folio/okapi/managers/ModuleManager.java | 4 ++-- okapi-core/src/main/raml/okapi.raml | 10 ++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/guide.md b/doc/guide.md index 4d46c9630..fb83851d0 100644 --- a/doc/guide.md +++ b/doc/guide.md @@ -1100,6 +1100,11 @@ posted. Note that Okapi gives us less details about the modules, for in the real life this could be quite a long list. +Modules are immutable (for same id). There is no PUT method to update a module. +It is possible to POST the module descriptor again, if it is equivalent to the +existing module. This enforcement can be lifted, by supplying query +parameter `check=false`. + #### Deploying the module It is not enough that Okapi knows that such a module exists. We must diff --git a/okapi-core/src/main/java/org/folio/okapi/managers/ModuleManager.java b/okapi-core/src/main/java/org/folio/okapi/managers/ModuleManager.java index 31bd0050c..f37870b38 100644 --- a/okapi-core/src/main/java/org/folio/okapi/managers/ModuleManager.java +++ b/okapi-core/src/main/java/org/folio/okapi/managers/ModuleManager.java @@ -78,7 +78,7 @@ private Future loadModules() { * Create a list of modules. * * @param list list of modules - * @param check whether to check dependencies + * @param check whether to check dependencies and immutability of existing modules * @param removeIfMissingDep skip modules where dependency check fails * @return future */ @@ -91,7 +91,7 @@ public Future createList(List list, boolean check, * Create a list of modules. * * @param list list of modules - * @param check whether to check dependencies + * @param check whether to check dependencies and immutability of existing modules * @param moduleVersionFilter whether to allow pre-release/npmSnapshots * @param removeIfMissingDep skip modules where dependency check fails * @return future diff --git a/okapi-core/src/main/raml/okapi.raml b/okapi-core/src/main/raml/okapi.raml index 4afa97767..089759ba5 100644 --- a/okapi-core/src/main/raml/okapi.raml +++ b/okapi-core/src/main/raml/okapi.raml @@ -453,7 +453,10 @@ traits: /_/proxy/modules. queryParameters: check: - description: Whether to check dependencies + description: Whether to check dependencies and immutability of existing modules. + If false, modules may be imported requiring interfaces that are not currently + offered by any other module. Also with a false value an existing module may be + updated; thus breaking immutability. type: boolean required: false default: true @@ -530,7 +533,10 @@ traits: selected for a specific tenant. queryParameters: check: - description: Whether to check dependencies + description: Whether to check dependencies and immutability of existing modules. + If false, a module may be imported requiring interfaces that are not currently + offered by any other module. Also with a false value an existing module may + be updated; thus breaking immutability. type: boolean required: false default: true From 5efe4ab4cb53caf27d8a072831e08cdda3344687 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 27 Mar 2026 12:04:06 +0100 Subject: [PATCH 3/3] Add test --- .../src/test/java/org/folio/okapi/ModuleTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/okapi-core/src/test/java/org/folio/okapi/ModuleTest.java b/okapi-core/src/test/java/org/folio/okapi/ModuleTest.java index 08969a767..6c3342219 100644 --- a/okapi-core/src/test/java/org/folio/okapi/ModuleTest.java +++ b/okapi-core/src/test/java/org/folio/okapi/ModuleTest.java @@ -948,6 +948,17 @@ public void testOneModule(TestContext context) { .body(equalTo("create: module sample-module-1+1 already exists")); assertEmptyReport(c); + // post it again with slight modification, but check=false, so it should be allowed, and replace the old one + c = api.createRestAssured3(); + c.given() + .header("Content-Type", "application/json") + .body(docSampleModule.replace("sample.extra\"", "sample.foo\"")) + .queryParam("check", "false") + .post("/_/proxy/modules") + .then() + .statusCode(201); + assertEmptyReport(c); + given() .header("Content-Type", "application/json") .body("{}")