Skip to content

Commit 4a88283

Browse files
authored
Do not add as exception fields leaf objects (#2277)
Some fields were excluded (leaf objects) as exception fields, those fields should not be added as part of the exception list. That exception caused that some fields in airflow package were not detected as undocumented as they should.
1 parent f7de70c commit 4a88283

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

internal/fields/exception_fields.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func (v *Validator) listExceptionFieldsMapElement(root string, elem common.MapSt
3838
default:
3939
if skipLeafOfObject(root, name, v.specVersion, v.Schema) {
4040
// Till some versions we skip some validations on leaf of objects, check if it is the case.
41-
all = append(all, root)
4241
break
4342
}
4443

@@ -124,6 +123,7 @@ func (v *Validator) parseExceptionField(key string, definition FieldDefinition,
124123
return v.parseExceptionField(key, definition, val)
125124
case definition.Type == "object" && definition.ObjectType == "":
126125
// 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)
127127
return []string{key}
128128
}
129129

internal/fields/mappings.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ func getMappingDefinitionsField(field string, definition map[string]any) (map[st
451451
anyValue := definition[field]
452452
object, ok := anyValue.(map[string]any)
453453
if !ok {
454-
return nil, fmt.Errorf("unexpected type found for %s: %T ", field, anyValue)
454+
return nil, fmt.Errorf("unexpected type found for %q: %T ", field, anyValue)
455455
}
456456
return object, nil
457457
}
@@ -493,22 +493,22 @@ func (v *MappingValidator) compareMappings(path string, preview, actual map[stri
493493
}
494494

495495
if slices.Contains(v.exceptionFields, path) {
496-
logger.Warnf("Found exception field, skip its validation: %s", path)
496+
logger.Warnf("Found exception field, skip its validation: %q", path)
497497
return nil
498498
}
499499

500500
if isObjectFullyDynamic(actual) {
501-
logger.Debugf("Dynamic object found but no fields ingested under path: %s.*", path)
501+
logger.Debugf("Dynamic object found but no fields ingested under path: \"%s.*\"", path)
502502
return nil
503503
}
504504

505505
if isObject(actual) {
506506
if isObjectFullyDynamic(preview) {
507507
// TODO: Skip for now, it should be required to compare with dynamic templates
508-
logger.Debugf("Pending to validate with the dynamic templates defined the path: %s", path)
508+
logger.Debugf("Pending to validate with the dynamic templates defined the path: %q", path)
509509
return nil
510510
} else if !isObject(preview) {
511-
errs = append(errs, fmt.Errorf("not found properties in preview mappings for path: %s", path))
511+
errs = append(errs, fmt.Errorf("not found properties in preview mappings for path: %q", path))
512512
return errs.Unique()
513513
}
514514
previewProperties, err := getMappingDefinitionsField("properties", preview)
@@ -531,7 +531,7 @@ func (v *MappingValidator) compareMappings(path string, preview, actual map[stri
531531
containsMultifield := isMultiFields(actual)
532532
if containsMultifield {
533533
if !isMultiFields(preview) {
534-
errs = append(errs, fmt.Errorf("not found multi_fields in preview mappings for path: %s", path))
534+
errs = append(errs, fmt.Errorf("not found multi_fields in preview mappings for path: %q", path))
535535
return errs.Unique()
536536
}
537537
previewFields, err := getMappingDefinitionsField("fields", preview)
@@ -604,7 +604,7 @@ func (v *MappingValidator) validateMappingsNotInPreview(currentPath string, chil
604604

605605
for fieldPath, object := range flattenFields {
606606
if slices.Contains(v.exceptionFields, fieldPath) {
607-
logger.Warnf("Found exception field, skip its validation: %s", fieldPath)
607+
logger.Warnf("Found exception field, skip its validation: %q", fieldPath)
608608
return nil
609609
}
610610

internal/fields/mappings_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func TestComparingMappings(t *testing.T) {
307307
},
308308
schema: []FieldDefinition{},
309309
expectedErrors: []string{
310-
`not found multi_fields in preview mappings for path: foo`,
310+
`not found multi_fields in preview mappings for path: "foo"`,
311311
},
312312
},
313313
{

0 commit comments

Comments
 (0)