From 9085e79ba28d77e36113c5897137db532ec37839 Mon Sep 17 00:00:00 2001 From: Binal Patel Date: Wed, 20 Aug 2025 12:35:01 -0700 Subject: [PATCH 1/2] Log an error instead of throwing an IllegalArgumentException (since it isn't captured in server logs). Improve error messages by including the source trigger script name as a parameter. --- .../ldk/query/LookupValidationHelper.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/LDK/src/org/labkey/ldk/query/LookupValidationHelper.java b/LDK/src/org/labkey/ldk/query/LookupValidationHelper.java index 31196d92..f1a1542b 100644 --- a/LDK/src/org/labkey/ldk/query/LookupValidationHelper.java +++ b/LDK/src/org/labkey/ldk/query/LookupValidationHelper.java @@ -193,12 +193,12 @@ public void cascadeUpdate(String targetSchema, String targetTable, String target qus.updateRows(_user, _container, toUpdate, oldPKs, null, new HashMap<>()); } - public boolean verifyNotUsed(String targetSchema, String targetTable, String targetField, Object val) throws SQLException + public boolean verifyNotUsed(String targetSchema, String targetTable, String targetField, Object val, String triggerScriptName) throws SQLException { - return verifyNotUsed(targetSchema, targetTable, targetField, val, null); + return verifyNotUsed(targetSchema, targetTable, targetField, val, null, triggerScriptName); } - public boolean verifyNotUsed(String targetSchema, String targetTable, String targetField, Object val, @Nullable String containerPath) throws SQLException + public boolean verifyNotUsed(String targetSchema, String targetTable, String targetField, Object val, @Nullable String containerPath, String triggerScriptName) throws SQLException { Container c = _container; if (containerPath != null) @@ -212,14 +212,23 @@ public boolean verifyNotUsed(String targetSchema, String targetTable, String tar UserSchema us = QueryService.get().getUserSchema(_user, c, targetSchema); if (us == null) - throw new IllegalArgumentException("Unknown schema: " + targetSchema); + { + _log.error("Error running '" + triggerScriptName + "' trigger script. Schema '{}' not found in container '{}'", targetSchema, c.getName()); + return false; + } TableInfo ti = us.getTable(targetTable); if (ti == null) - throw new IllegalArgumentException("Unknown table: " + targetTable); + { + _log.error("Error running '" + triggerScriptName + "' trigger script. Table '{}' not found in container '{}'", targetTable, c.getName()); + return false; + } if (ti.getColumn(targetField) == null) - throw new IllegalArgumentException("Unknown column: " + targetField + " in table: " + targetTable); + { + _log.error("Error running '" + triggerScriptName + "' trigger script. Column '{}' not found in table '{}'", targetField, targetTable); + return false; + } TableSelector ts = new TableSelector(ti, new SimpleFilter(FieldKey.fromString(targetField), val), null); From d62aff821493cb179e6aac8db36acdff74471aeb Mon Sep 17 00:00:00 2001 From: Binal Patel Date: Wed, 20 Aug 2025 21:59:42 -0700 Subject: [PATCH 2/2] Add error log. --- LDK/src/org/labkey/ldk/query/LookupValidationHelper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LDK/src/org/labkey/ldk/query/LookupValidationHelper.java b/LDK/src/org/labkey/ldk/query/LookupValidationHelper.java index f1a1542b..05c22d15 100644 --- a/LDK/src/org/labkey/ldk/query/LookupValidationHelper.java +++ b/LDK/src/org/labkey/ldk/query/LookupValidationHelper.java @@ -206,7 +206,8 @@ public boolean verifyNotUsed(String targetSchema, String targetTable, String tar c = ContainerManager.getForPath(containerPath); if (c == null) { - throw new IllegalArgumentException("Unknown container: " + containerPath); + _log.error("Error running '" + triggerScriptName + "' trigger script. Container '{}' not found", containerPath); + return false; } }