Skip to content

Backport 2049 to 2.18#2050

Open
manaswini1920 wants to merge 1 commit intoopensearch-project:2.18from
manaswini1920:backport-2049-to-2.18
Open

Backport 2049 to 2.18#2050
manaswini1920 wants to merge 1 commit intoopensearch-project:2.18from
manaswini1920:backport-2049-to-2.18

Conversation

@manaswini1920
Copy link
Contributor

Description

A nested field with type nested but no sub-properties (e.g. "http_request_headers": {"type": "nested"}) causes a NullPointerException during doc-level monitor creation.

In DocLevelMonitorQueries.traverseMappingsAndUpdate(), the code assumes all non-leaf nodes have a properties map. When a field has type: "nested", it's treated as an internal node and the code unconditionally
casts nodeProps["properties"] to MutableMap<String, Any>. If the nested field has no sub-properties, this is null, causing the crash.

Fix: Added a null guard before recursing into nested field properties. Fields with type: "nested" and no properties are now safely skipped during traversal.

Testing: Added unit tests to AlertingUtilsTests covering both cases:

Nested field without properties — skipped, no exception
Nested field with properties — sub-fields traversed correctly

Related Issues

backport #2049

Check List

  • [ X] New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • [ X] Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…opensearch-project#2049)

A nested field with type 'nested' but no sub-properties causes a
NullPointerException during doc-level monitor creation. The
traverseMappingsAndUpdate method assumes all non-leaf nodes have a
'properties' map, but nested fields without sub-properties have none.

Added a null guard before recursing into nested field properties.
Fields with type 'nested' and no properties are now safely skipped.

Resolves opensearch-project/security-analytics#1472

Signed-off-by: Manaswini Ragamouni <manaswini1920@gmail.com>
Signed-off-by: Manaswini Ragamouni <ragamanu@amazon.com>
Co-authored-by: Manaswini Ragamouni <ragamanu@amazon.com>
(cherry picked from commit 9b31fab)
Signed-off-by: Manaswini Ragamouni <ragamanu@amazon.com>
@manaswini1920 manaswini1920 force-pushed the backport-2049-to-2.18 branch from 61981d8 to c105c50 Compare March 24, 2026 01:02
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.

1 participant