Skip to content

Commit

Permalink
Fix httpjson split issue on empty root array (#32001) (#33103)
Browse files Browse the repository at this point in the history
* Fix httpjson split issue on empty root arrayPublish events

* update asciidoc

* update changelog

* remove old lines

(cherry picked from commit 0334634)

Co-authored-by: Krishna Chaitanya Reddy Burri <krish.reddy91@gmail.com>
  • Loading branch information
mergify[bot] and kcreddy authored Sep 20, 2022
1 parent bd3a3c7 commit 3359888
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]
*Filebeat*

- Fix handling of Cisco 302020 messages in ASA and FTD modules. {pull}33089[33089]
- Fix handling of empty array in httpjson input. {pull}32001[32001]


*Heartbeat*

Expand Down
1 change: 1 addition & 0 deletions x-pack/filebeat/input/httpjson/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (s *split) split(ctx *transformContext, root mapstr.M, ch chan<- maybeMsg)
return nil
}
if s.isRoot {
ch <- maybeMsg{msg: root}
return errEmptyRootField
}
ch <- maybeMsg{msg: root}
Expand Down
15 changes: 10 additions & 5 deletions x-pack/filebeat/input/httpjson/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,11 @@ func TestSplit(t *testing.T) {
},
},
{
name: "First level split skips publish if no events",
name: "First level split publishes with key if no events",
config: &splitConfig{
Target: "body.response",
Type: "array",
Target: "body.response",
Type: "array",
KeepParent: true,
Split: &splitConfig{
Target: "body.Event.Attributes",
KeepParent: true,
Expand All @@ -292,8 +293,12 @@ func TestSplit(t *testing.T) {
"response": []interface{}{},
},
},
expectedMessages: []mapstr.M{},
expectedErr: errEmptyRootField,
expectedMessages: []mapstr.M{
{
"response": []interface{}{},
},
},
expectedErr: errEmptyRootField,
},
{
name: "Changes must be local to parent when nested splits",
Expand Down

0 comments on commit 3359888

Please sign in to comment.