Skip to content

TIKA-4859: Accept enum values in JSON config case-insensitively - #3097

Merged
THausherr merged 4 commits into
apache:mainfrom
dschmidt:config-enum-case
Aug 30, 2026
Merged

TIKA-4859: Accept enum values in JSON config case-insensitively#3097
THausherr merged 4 commits into
apache:mainfrom
dschmidt:config-enum-case

Conversation

@dschmidt

Copy link
Copy Markdown
Contributor

The server docs show "strategy": "no_ocr", but enum values were matched by Enum.valueOf, so that request answered 422 while NO_OCR worked. This enables ACCEPT_CASE_INSENSITIVE_ENUMS on 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ENUMS on the shared ObjectMapper used 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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded.

Comment thread CHANGES.txt Outdated
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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded.

@THausherr
THausherr merged commit 6d66308 into apache:main Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants