Skip to content

Commit cdb006d

Browse files
authored
[Hearbteat]Set expected url format in case of parsing error (#37255)
URL mappings expect an object type, whereas heartbeat is setting it as a string in case of a parsing error. Fix that by appending url.full with the faulty url.
1 parent 0baba39 commit cdb006d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

CHANGELOG.next.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
9898
*Heartbeat*
9999

100100
- Fix panics when parsing dereferencing invalid parsed url. {pull}34702[34702]
101+
- Fix mapping errors with invalid urls. {pull}37255[37255]
101102

102103
*Metricbeat*
103104

x-pack/heartbeat/monitors/browser/synthexec/synthtypes.go

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (se SynthEvent) ToMap() (m mapstr.M) {
9595
if se.URL != "" {
9696
u, e := url.Parse(se.URL)
9797
if e != nil {
98+
_, _ = m.Put("url", mapstr.M{"full": se.URL})
9899
logp.L().Warn("Could not parse synthetics URL '%s': %s", se.URL, e.Error())
99100
} else {
100101
_, _ = m.Put("url", wraputil.URLFields(u))

x-pack/heartbeat/monitors/browser/synthexec/synthtypes_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,31 @@ func TestToMap(t *testing.T) {
5959
"truly_at_root": "v2",
6060
},
6161
},
62+
{
63+
"root fields with invalid URL",
64+
mapstr.M{
65+
"type": JourneyStart,
66+
"package_version": "1.2.3",
67+
"root_fields": map[string]interface{}{
68+
"synthetics": map[string]interface{}{
69+
"nested": "v1",
70+
},
71+
"truly_at_root": "v2",
72+
},
73+
"url": "https://{example}.com",
74+
},
75+
mapstr.M{
76+
"synthetics": mapstr.M{
77+
"type": JourneyStart,
78+
"package_version": "1.2.3",
79+
"nested": "v1",
80+
},
81+
"url": mapstr.M{
82+
"full": "https://{example}.com",
83+
},
84+
"truly_at_root": "v2",
85+
},
86+
},
6287
{
6388
"root fields, step metadata",
6489
mapstr.M{

0 commit comments

Comments
 (0)