55package fields
66
77import (
8+ "slices"
89 "strings"
910
1011 "github.com/elastic/elastic-package/internal/common"
@@ -37,6 +38,8 @@ func (v *Validator) listExceptionFieldsMapElement(root string, elem common.MapSt
3738 all = append (all , fields ... )
3839 default :
3940 if skipLeafOfObject (root , name , v .specVersion , v .Schema ) {
41+ logger .Tracef ("Skip validating leaf of object (spec %q): %q" , v .specVersion , key )
42+ all = append (all , key )
4043 // Till some versions we skip some validations on leaf of objects, check if it is the case.
4144 break
4245 }
@@ -45,6 +48,8 @@ func (v *Validator) listExceptionFieldsMapElement(root string, elem common.MapSt
4548 all = append (all , fields ... )
4649 }
4750 }
51+ slices .Sort (all )
52+ all = slices .Compact (all )
4853 return all
4954}
5055
@@ -86,7 +91,7 @@ func (v *Validator) parseExceptionField(key string, definition FieldDefinition,
8691 case "ip" :
8792 case "array" :
8893 if v .specVersion .LessThan (semver2_0_0 ) {
89- logger .Warnf ("Skip validating field of type array with spec < 2.0.0 (key %q type %q spec %q)" , key , definition .Type , v .specVersion )
94+ logger .Tracef ("Skip validating field of type array with spec < 2.0.0 (key %q type %q spec %q)" , key , definition .Type , v .specVersion )
9095 return []string {key }
9196 }
9297 return nil
@@ -97,21 +102,21 @@ func (v *Validator) parseExceptionField(key string, definition FieldDefinition,
97102 // This is probably an element from an array of objects,
98103 // even if not recommended, it should be validated.
99104 if v .specVersion .LessThan (semver3_0_1 ) {
100- logger .Warnf ("Skip validating object (map[string]any) in package spec < 3.0.1 (key %q type %q spec %q)" , key , definition .Type , v .specVersion )
105+ logger .Tracef ("Skip validating object (map[string]any) in package spec < 3.0.1 (key %q type %q spec %q)" , key , definition .Type , v .specVersion )
101106 return []string {key }
102107 }
103108 return nil
104109 case []any :
105110 // This can be an array of array of objects. Elasticsearh will probably
106111 // flatten this. So even if this is quite unexpected, let's try to handle it.
107112 if v .specVersion .LessThan (semver3_0_1 ) {
108- logger .Warnf ("Skip validating object ([]any) because spec < 3.0.1 (key %q type %q spec %q)" , key , definition .Type , v .specVersion )
113+ logger .Tracef ("Skip validating object ([]any) because spec < 3.0.1 (key %q type %q spec %q)" , key , definition .Type , v .specVersion )
109114 return []string {key }
110115 }
111116 return nil
112117 case nil :
113118 // The document contains a null, let's consider this like an empty array.
114- logger .Warnf ("Skip validating object empty array because spec < 3.0.1 (key %q type %q spec %q)" , key , definition .Type , v .specVersion )
119+ logger .Tracef ("Skip validating object empty array because spec < 3.0.1 (key %q type %q spec %q)" , key , definition .Type , v .specVersion )
115120 return []string {key }
116121 default :
117122 switch {
@@ -123,7 +128,7 @@ func (v *Validator) parseExceptionField(key string, definition FieldDefinition,
123128 return v .parseExceptionField (key , definition , val )
124129 case definition .Type == "object" && definition .ObjectType == "" :
125130 // Legacy mapping, ambiguous definition not allowed by recent versions of the spec, ignore it.
126- logger .Warnf ("Skip legacy mapping: object field without \" object_type\" parameter: %q" , key )
131+ logger .Tracef ("Skip legacy mapping: object field without \" object_type\" parameter: %q" , key )
127132 return []string {key }
128133 }
129134
0 commit comments