This is an automated email from the ASF dual-hosted git repository. tballison pushed a commit to branch TIKA-4809-stage-7 in repository https://gitbox.apache.org/repos/asf/tika.git
commit 2b4216f77ac471e1035d897dd4b0f089e9ab6ce9 Author: tallison <[email protected]> AuthorDate: Mon Aug 10 11:06:16 2026 -0400 TIKA-4809: Fail on unrecognized parse-context component names --- .../org/apache/tika/serialization/ParseContextUtils.java | 10 +++++----- .../serialization/TestParseContextSerialization.java | 16 ++++++++++++++++ .../test/resources/configs/cxf-unpack-test-template.json | 10 ++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/tika-serialization/src/main/java/org/apache/tika/serialization/ParseContextUtils.java b/tika-serialization/src/main/java/org/apache/tika/serialization/ParseContextUtils.java index 179b6ae897..010d4041fe 100644 --- a/tika-serialization/src/main/java/org/apache/tika/serialization/ParseContextUtils.java +++ b/tika-serialization/src/main/java/org/apache/tika/serialization/ParseContextUtils.java @@ -126,11 +126,11 @@ public class ParseContextUtils { // Try to find this friendly name in any registered component registry var optionalInfo = ComponentNameResolver.getComponentInfo(friendlyName); if (optionalInfo.isEmpty()) { - // Not a registered component -- ignored (not applied). WARN so a typo'd config key - // is visible rather than silently dropped. - LOG.warn("Ignoring unrecognized parse-context entry '{}' (not a registered " - + "component); check for a typo", friendlyName); - continue; + // Fail rather than warn: parse-context is where the DoS limits live + // (timeout-limits, embedded-limits, output-limits), so a typo'd name + // silently reverts to defaults an operator believes they overrode. + throw new TikaConfigException("Unrecognized parse-context entry '" + friendlyName + + "'. Check for a typo; it does not match any registered component."); } ComponentInfo info = optionalInfo.get(); diff --git a/tika-serialization/src/test/java/org/apache/tika/serialization/TestParseContextSerialization.java b/tika-serialization/src/test/java/org/apache/tika/serialization/TestParseContextSerialization.java index 44cda725f4..32b73d7503 100644 --- a/tika-serialization/src/test/java/org/apache/tika/serialization/TestParseContextSerialization.java +++ b/tika-serialization/src/test/java/org/apache/tika/serialization/TestParseContextSerialization.java @@ -34,6 +34,7 @@ import org.junit.jupiter.api.Test; import org.apache.tika.config.TimeoutLimits; import org.apache.tika.config.loader.TikaObjectMapperFactory; +import org.apache.tika.exception.TikaConfigException; import org.apache.tika.extractor.DocumentSelector; import org.apache.tika.extractor.SkipEmbeddedDocumentSelector; import org.apache.tika.metadata.filter.AttachmentCountingListFilter; @@ -527,4 +528,19 @@ public class TestParseContextSerialization { assertNotNull(deserialized.get(ContentHandlerFactory.class)); assertNotNull(deserialized.get(DocumentSelector.class)); } + @Test + public void testUnrecognizedComponentNameFails() throws Exception { + // parse-context carries the DoS limits, so a typo must not silently fall back + // to defaults the operator believes they overrode. + ObjectMapper mapper = createMapper(); + ParseContext ctx = mapper.readValue( + "{\"timeout-limitz\": {\"totalTaskTimeoutMillis\": 5000}}", ParseContext.class); + + TikaConfigException e = assertThrows(TikaConfigException.class, + () -> ParseContextUtils.resolveAll(ctx, + Thread.currentThread().getContextClassLoader())); + assertTrue(e.getMessage().contains("timeout-limitz"), + "the message must name the offending key: " + e.getMessage()); + } + } diff --git a/tika-server/tika-server-core/src/test/resources/configs/cxf-unpack-test-template.json b/tika-server/tika-server-core/src/test/resources/configs/cxf-unpack-test-template.json index 29e27e005f..e1b628a84f 100644 --- a/tika-server/tika-server-core/src/test/resources/configs/cxf-unpack-test-template.json +++ b/tika-server/tika-server-core/src/test/resources/configs/cxf-unpack-test-template.json @@ -25,12 +25,10 @@ "throwOnZeroBytes": false }, "parse-context": { - "digester-factory": { - "commons-digester-factory": { - "digests": [ - { "algorithm": "MD5" } - ] - } + "commons-digester-factory": { + "digests": [ + { "algorithm": "MD5" } + ] }, "timeout-limits": { "progressTimeoutMillis": "TIMEOUT_MILLIS"
