TIKA-4859: Accept enum values in JSON config case-insensitively - #3097
Merged
Conversation
… the no_ocr docs example
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Tika’s JSON configuration deserialization to accept enum values case-insensitively, addressing a mismatch between documented config examples and actual behavior (TIKA-4859).
Changes:
- Enable Jackson
ACCEPT_CASE_INSENSITIVE_ENUMSon the sharedObjectMapperused for JSON config loading. - Add a unit test verifying case-insensitive enum parsing and that unknown enum values still fail.
- Update server documentation examples and add a CHANGES entry for the behavior change.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tika-serialization/src/main/java/org/apache/tika/config/loader/TikaObjectMapperFactory.java |
Enables case-insensitive enum matching on the JSON-config ObjectMapper. |
tika-serialization/src/test/java/org/apache/tika/config/loader/TikaObjectMapperFactoryTest.java |
Adds regression tests for enum case-insensitivity and unknown-value failure. |
docs/modules/ROOT/pages/using-tika/server/index.adoc |
Updates a multipart config example enum value casing. |
docs/modules/ROOT/pages/migration-to-4x/migrating-tika-server-4x.adoc |
Updates a multipart config example enum value casing. |
CHANGES.txt |
Notes the case-insensitive enum behavior change for the upcoming release. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+130
to
+132
| // Accept enum values in any case ("no_ocr" as well as "NO_OCR"), the | ||
| // documented examples and hand-written requests use both | ||
| mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true); |
Comment on lines
+3
to
+4
| * Enum values in JSON configuration are matched case-insensitively, so the | ||
| documented "no_ocr" works as well as "NO_OCR" (TIKA-4859). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The server docs show
"strategy": "no_ocr", but enum values were matched byEnum.valueOf, so that request answered 422 whileNO_OCRworked. This enablesACCEPT_CASE_INSENSITIVE_ENUMSon the Tika ObjectMapper (unknown values still fail) and fixes the two docs examples. If you would rather keep enums strict, the docs fix alone closes the ticket.https://issues.apache.org/jira/browse/TIKA-4859