From e4fd6e4cc6f3be9b7d89db0d2f2aa302b669eac6 Mon Sep 17 00:00:00 2001 From: Julian Ladisch Date: Thu, 25 Jul 2024 11:01:38 +0200 Subject: [PATCH] MODINVSTOR-1237: Don't warn about expected 403 response from user-tenants https://folio-org.atlassian.net/browse/MODINVSTOR-1237 See https://folio-org.atlassian.net/browse/MODINVSTOR-1114 why it is expected that ConsortiumDataCache gets a 403 response when calling /user-tenants. That 403 causes this log entry: `WARN ConsortiumDataCache loadConsortiumData:: Error loading consortium data, tenantId: 'diku' response status: '403', body: 'Access for user 'diku_admin' (2579bfce-29bd-435a-bac6-5e1b95588e31) requires permission: user-tenants.collection.get'` Warning about an expected 403 is misleading. Solution: INFO ConsortiumDataCache loadConsortiumData:: Skipping for tenant diku because /user-tenants?limit=1 returns 403 (forbidden) --- NEWS.md | 1 + .../org/folio/services/caches/ConsortiumDataCache.java | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8f6fc9b4d..ae8b6fed1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,7 @@ * Implement domain event production for institution create/update/delete ([MODINVSTOR-1218](https://issues.folio.org/browse/MODINVSTOR-1218)) * Implement a POST request to get Holdings and Instances ([MODINVSTOR-1223](https://folio-org.atlassian.net/browse/MODINVSTOR-1223)) * Implement instance-date-types endpoint ([MODINVSTOR-1235](https://folio-org.atlassian.net/browse/MODINVSTOR-1235)) +* Info, not warn, about expected 403 from /user-tenants ([MODINVSTOR-1237](https://folio-org.atlassian.net/browse/MODINVSTOR-1237)) ### Bug fixes * Unintended update of instance records \_version (optimistic locking) whenever any of its holdings or items are created, updated or deleted. ([MODINVSTOR-1186](https://folio-org.atlassian.net/browse/MODINVSTOR-1186)) diff --git a/src/main/java/org/folio/services/caches/ConsortiumDataCache.java b/src/main/java/org/folio/services/caches/ConsortiumDataCache.java index 4db1905da..675a70a08 100644 --- a/src/main/java/org/folio/services/caches/ConsortiumDataCache.java +++ b/src/main/java/org/folio/services/caches/ConsortiumDataCache.java @@ -68,14 +68,15 @@ private CompletableFuture> loadConsortiumData(String te headers.forEach(request::putHeader); return request.send().compose(response -> { + if (response.statusCode() == HTTP_FORBIDDEN) { + LOG.info("loadConsortiumData:: Skipping for tenant {} because {} returns 403 (forbidden)", + tenantId, USER_TENANTS_PATH); + return Future.succeededFuture(Optional.empty()); + } if (response.statusCode() != HTTP_OK) { String msg = String.format("Error loading consortium data, tenantId: '%s' response status: '%s', body: '%s'", tenantId, response.statusCode(), response.bodyAsString()); LOG.warn("loadConsortiumData:: {}", msg); - if (response.statusCode() == HTTP_FORBIDDEN) { - return Future.succeededFuture(Optional.empty()); - } - return Future.failedFuture(msg); } JsonArray userTenants = response.bodyAsJsonObject().getJsonArray(USER_TENANTS_FIELD);