From 20897c01bd265174f3576adc5d4458b77f2c8754 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Thu, 18 Jul 2024 06:56:56 +0930 Subject: [PATCH] mod: update elastic/mito to version v1.14.0 This brings error-handling improvements. * better error localisation in error snippets * fixed handling of errors containing Go fmt verb syntax --- CHANGELOG.next.asciidoc | 5 +-- NOTICE.txt | 4 +- go.mod | 2 +- go.sum | 4 +- .../filebeat/docs/inputs/input-cel.asciidoc | 2 +- x-pack/filebeat/input/cel/input_test.go | 38 ++++++++++++++----- 6 files changed, 37 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index a9b6439adf24..d9856f603224 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -159,8 +159,6 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] *Heartbeat* -*Heartbeat* - *Metricbeat* @@ -302,7 +300,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Allow elision of set and append failure logging. {issue}34544[34544] {pull}39929[39929] - Add ability to remove request trace logs from CEL input. {pull}39969[39969] - Add ability to remove request trace logs from HTTPJSON input. {pull}40003[40003] -- Update CEL mito extensions to v1.13.0 {pull}40035[40035] +- Update CEL mito extensions to v1.13.0. {pull}40035[40035] - Add Jamf entity analytics provider. {pull}39996[39996] - Add ability to remove request trace logs from http_endpoint input. {pull}40005[40005] - Add ability to remove request trace logs from entityanalytics input. {pull}40004[40004] @@ -310,6 +308,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Implement Elastic Agent status and health reporting for Netflow Filebeat input. {pull}40080[40080] - Enhance input state reporting for CEL evaluations that return a single error object in events. {pull}40083[40083] - Allow absent credentials when using GCS with Application Default Credentials. {issue}39977[39977] {pull}40072[40072] +- Update CEL mito extensions to v1.14.0. {pull}40294[40294] *Auditbeat* diff --git a/NOTICE.txt b/NOTICE.txt index 34189b6e74d3..0df8b1cce838 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -15785,11 +15785,11 @@ limitations under the License. -------------------------------------------------------------------------------- Dependency : github.com/elastic/mito -Version: v1.13.0 +Version: v1.14.0 Licence type (autodetected): Apache-2.0 -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/elastic/mito@v1.13.0/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/elastic/mito@v1.14.0/LICENSE: Apache License diff --git a/go.mod b/go.mod index 02387bf18c52..d919df027d9f 100644 --- a/go.mod +++ b/go.mod @@ -199,7 +199,7 @@ require ( github.com/elastic/elastic-agent-system-metrics v0.10.3 github.com/elastic/go-elasticsearch/v8 v8.14.0 github.com/elastic/go-sfdc v0.0.0-20240621062639-bcc8456508ff - github.com/elastic/mito v1.13.0 + github.com/elastic/mito v1.14.0 github.com/elastic/tk-btf v0.1.0 github.com/elastic/toutoumomoma v0.0.0-20221026030040-594ef30cb640 github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15 diff --git a/go.sum b/go.sum index ebfeadc231bd..a628d95786c6 100644 --- a/go.sum +++ b/go.sum @@ -585,8 +585,8 @@ github.com/elastic/gopacket v1.1.20-0.20211202005954-d412fca7f83a h1:8WfL/X6fK11 github.com/elastic/gopacket v1.1.20-0.20211202005954-d412fca7f83a/go.mod h1:riddUzxTSBpJXk3qBHtYr4qOhFhT6k/1c0E3qkQjQpA= github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/uo= github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= -github.com/elastic/mito v1.13.0 h1:8S75e9UQ/r4S2Ch/oxgrFxquvPsFifoQgHEnI2VzZTE= -github.com/elastic/mito v1.13.0/go.mod h1:J+wCf4HccW2YoSFmZMGu+d06gN+WmnIlj5ehBqine74= +github.com/elastic/mito v1.14.0 h1:QbyqIuob+JXvygqB01C9KlqEThGx5p8n55HiFTSiMm8= +github.com/elastic/mito v1.14.0/go.mod h1:J+wCf4HccW2YoSFmZMGu+d06gN+WmnIlj5ehBqine74= github.com/elastic/pkcs8 v1.0.0 h1:HhitlUKxhN288kcNcYkjW6/ouvuwJWd9ioxpjnD9jVA= github.com/elastic/pkcs8 v1.0.0/go.mod h1:ipsZToJfq1MxclVTwpG7U/bgeDtf+0HkUiOxebk95+0= github.com/elastic/ristretto v0.1.1-0.20220602190459-83b0895ca5b3 h1:ChPwRVv1RR4a0cxoGjKcyWjTEpxYfm5gydMIzo32cAw= diff --git a/x-pack/filebeat/docs/inputs/input-cel.asciidoc b/x-pack/filebeat/docs/inputs/input-cel.asciidoc index 1366e7cc7892..35c513d2df25 100644 --- a/x-pack/filebeat/docs/inputs/input-cel.asciidoc +++ b/x-pack/filebeat/docs/inputs/input-cel.asciidoc @@ -1,7 +1,7 @@ [role="xpack"] :type: cel -:mito_version: v1.13.0 +:mito_version: v1.14.0 :mito_docs: https://pkg.go.dev/github.com/elastic/mito@{mito_version} [id="{beatname_lc}-input-{type}"] diff --git a/x-pack/filebeat/input/cel/input_test.go b/x-pack/filebeat/input/cel/input_test.go index 442b404458dd..6ef9dcbc824e 100644 --- a/x-pack/filebeat/input/cel/input_test.go +++ b/x-pack/filebeat/input/cel/input_test.go @@ -1550,14 +1550,32 @@ var inputTests = []struct { // Programmer error. { - name: "type_error_message", + name: "type_error_message_compile_time", server: newChainTestServer(httptest.NewServer), config: map[string]interface{}{ "interval": 1, "program": ` - bytes(get(state.url).Body).decode_json().records.map(r, - bytes(get(state.url+'/'+r.id).Body).decode_json()).as(events, { - // ^~~~ r.id not converted to string: can't add integer to string. + get(state.url).Body.decode_json().records.map(r, + get(state.url+'/'+int(r.id)).Body.decode_json()).as(events, { + // ^~~~ r.id converted to incorrect type. + "events": events, + }) + `, + }, + handler: defaultHandler(http.MethodGet, ""), + wantErr: fmt.Errorf(`failed to check program: failed compilation: ERROR: :3:20: found no matching overload for '_+_' applied to '(string, int)' + | get(state.url+'/'+int(r.id)).Body.decode_json()).as(events, { + | ...................^ accessing config`), + }, + { + name: "type_error_message_run_time", + server: newChainTestServer(httptest.NewServer), + config: map[string]interface{}{ + "interval": 1, + "program": ` + get(state.url).Body.decode_json().records.map(r, + get(state.url+'/'+r.id).Body.decode_json()).as(events, { + // ^~~~ r.id not converted to string: can't add integer to string. "events": events, }) `, @@ -1566,10 +1584,9 @@ var inputTests = []struct { want: []map[string]interface{}{ { "error": map[string]interface{}{ - // This is the best we get for some errors from CEL. - "message": `failed eval: ERROR: :3:56: no such overload - | bytes(get(state.url+'/'+r.id).Body).decode_json()).as(events, { - | .......................................................^`, + "message": `failed eval: ERROR: :3:26: no such overload + | get(state.url+'/'+r.id).Body.decode_json()).as(events, { + | .........................^`, }, }, }, @@ -1648,7 +1665,10 @@ func TestInput(t *testing.T) { conf.Redact = &redact{} // Make sure we pass the redact requirement. err := cfg.Unpack(&conf) if err != nil { - t.Fatalf("unexpected error unpacking config: %v", err) + if fmt.Sprint(err) != fmt.Sprint(test.wantErr) { + t.Fatalf("unexpected error unpacking config: %v", err) + } + return } var tempDir string