diff --git a/src/org/labkey/test/tests/LinkedSchemaTest.java b/src/org/labkey/test/tests/LinkedSchemaTest.java
index e42a545b13..d8494d75f9 100644
--- a/src/org/labkey/test/tests/LinkedSchemaTest.java
+++ b/src/org/labkey/test/tests/LinkedSchemaTest.java
@@ -15,6 +15,7 @@
*/
package org.labkey.test.tests;
+import org.assertj.core.api.Assertions;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -841,6 +842,62 @@ public void testCoreLinkedSchema()
assertTrue("Columns should have included 'Name': " + colNames, colNames.contains("Name"));
}
+ // coverage for Issue 50516: NPE from LinkedSchema$XmlFilterWhereClauseSource.getWhereClauses() when linked schema XML references bogus column
+ @Test
+ public void testCoreLinkedSchemaFilters()
+ {
+ String linkedSchemaName = "linkedCoreFilter";
+ String sourceContainerPath = "/" + getProjectName() + "/" + STUDY_FOLDER;
+
+ String badFilter = """
+
+
+
+
+
+
+ """;
+ String goodFilter = """
+
+
+
+
+
+
+ """;
+
+ log("Create the linked schema on core with a filter referencing a non-existent column");
+ _schemaHelper.createLinkedSchema(sourceContainerPath, linkedSchemaName, sourceContainerPath, null, "core", null, badFilter);
+
+ // browse to containers in the linked schema and verify the expected error
+ log("Verify the bogus filter gets an appropriate error");
+ goToSchemaBrowser();
+ selectQuery(linkedSchemaName, "containers");
+ // Issue 50516: NPE from LinkedSchema$XmlFilterWhereClauseSource.getWhereClauses() when linked schema XML references bogus column
+ waitForText("Error creating linked schema table 'containers': Filter column 'no_such_column' not found.");
+
+ // update the linked schema to use a good filter
+ _schemaHelper.updateLinkedSchema(sourceContainerPath, linkedSchemaName, sourceContainerPath, null, "core", null, goodFilter);
+
+ // browse to containers in the linked schema and view data in the containers table
+ log("Verify container is visible via linked schema via 'searchable=true' filter");
+ goToSchemaBrowser();
+ // finding the dataRegion here is already success
+ DataRegionTable table = viewQueryData(linkedSchemaName, "containers");
+ // ensure that the current container appears here as expected
+ checker().withScreenshot("current_container_not_present")
+ .wrapAssertion(()-> Assertions.assertThat(table.getRowIndex("Name", STUDY_FOLDER))
+ .as("container name not present in table")
+ .isGreaterThan(-1));
+
+ // clean up after ourselves
+ _schemaHelper.deleteSchema(sourceContainerPath, A_PEOPLE_SCHEMA_NAME);
+ }
+
/*
Test coverage : Issue 45347: Audit table data not available in linked schema
*/