[9.1] fix(mapper): handle VOID entries in _ignored_source with FLS (#141506)#144765
[9.1] fix(mapper): handle VOID entries in _ignored_source with FLS (#141506)#144765salvatore-campagna wants to merge 1 commit intoelastic:9.1from
Conversation
…#141506) Backport of elastic#141506 to 9.1. When Field Level Security is active on an index using synthetic source, fields with copy_to targets are recorded in _ignored_source as VOID entries. FieldSubsetReader attempted to parse these entries as CBOR, causing search failures with an unexpected Break token (0xFF). The fix checks hasValue() in decodeAsMap before parsing and returns null for VOID entries. FieldSubsetReader now skips null entries gracefully. Also unmutes the test from elastic#142341.
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
|
The I tried fixing this incrementally:
There may be more hidden behind these. Right now no PR targeting 9.1 can get a green |
|
Hi @salvatore-campagna , as far as I know If we need to backport these fixes to |
Because we have/had tests failing in CI: #142341 |
I thought that |
Backport Note
This is a backport of #141506 to 9.1. Closes #142341.
On 9.1,
FieldSubsetReader.javarequires an explicit null check for the return value ofdecodeAsMap(). On main, this class was refactored with anIgnoredSourceFormatparameter that handles nulls through a different code path, so the null check is not needed there.Also unmutes the test that was muted in #142341.
Problem
When Field Level Security (FLS) is active on an index using synthetic source, any field with a
copy_totarget causes search requests to fail with:The failure path is:
copy_totarget fields are recorded in_ignored_sourceas VOID entries (XContentDataHelper.voidValue()): markers indicating the field exists but its data is stored elsewhere (in thecopy_tosource field).FieldSubsetReaderiterates over_ignored_sourcestored fields and callsIgnoredSourceFieldMapper.decodeAsMapfor each entry to decide which fields to keep or strip based on FLS access permissions.decodeAsMapbuilds a CBOR object containing the field name but writes no value for VOID entries (XContentDataHelper.decodeAndWriteis a no-op). WhenXContentHelper.convertToMaptries to parse this malformed CBOR, the Jackson CBOR parser encounters an unexpected Break token (0xFF) and throws.Fix
The core fix is in
decodeAsMap(). It now checksnameValue.hasValue()before attempting to parse, returningnullfor VOID entries instead of building malformed CBOR.The
nullreturn propagates toFieldSubsetReader, which has an explicit null check and drops the entry. VOID entries carry no field data, so omitting them is correct.Tests
testDecodeAsMapReturnsNullForVoidEntry: unit test verifyingdecodeAsMapreturnsnullfor a VOID entry.testSyntheticSourceWithCopyToAndFLS: integration test exercisingFieldSubsetReaderwithcopy_to, synthetic source, and FLS.copy_to, and one covering theskip_ignored_source_readworkaround.