Repository navigation
fix(index): normalize invalid UTF-8 source bytes - #4
Merged
Merged
Conversation
- replace undecodable source bytes with deterministic Unicode replacement characters - keep valid UTF-8 and existing binary detection behavior unchanged - cover normalized line documents and JSON-safe deterministic actions
simianhacker
marked this pull request as ready for review
September 23, 2026 13:52
davemoore-
self-requested a review
September 23, 2026 18:10
davemoore-
approved these changes
Sep 23, 2026
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.
What
Normalize undecodable source bytes to Unicode replacement characters before constructing Elasticsearch file and line documents. This preserves valid UTF-8 exactly while preventing lone surrogate code points from causing bulk indexing failures.
The issue was reproduced while indexing
apache/grails-coreat commitfa1e14756daba70da13bde862d94056489171080. Legacy-encoded bytes ingrails-forge/grails-forge-api/src/test/resources/features_es.propertieswere decoded withsurrogateescape, producing lone surrogates such as\udcf3,\udcae, and\udce1. Elasticsearch rejected those line documents withInvalid UTF-8: Illegal surrogate character, leaving the ref incomplete.How to Verify
uv run --locked pytest tests/test_documents.py -v.uv run --locked pytest tests/ -v.Illegal surrogate characterbulk errors. The verified local run completed with 14,026 files and 1,324,487 lines.Breaking Changes
None