Skip to content

Commit 8ea9df4

Browse files
denikIsaac
andcommitted
Deduplicate required fields for shadowed embedded structs
Co-authored-by: Isaac <no-reply@databricks.com>
1 parent 9124e27 commit 8ea9df4

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎bundle/internal/validation/generated/required_fields.go‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎bundle/internal/validation/required.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,12 @@ func extractRequiredFields(typ reflect.Type) ([]RequiredPatternInfo, error) {
7878
return true
7979
}
8080

81+
// A struct that shadows an embedded field of the same JSON name (e.g. apps' lifecycle
82+
// over BaseResource's) is walked twice, so the same field can be reported twice.
8183
parentPath := path.Parent().String()
82-
fieldsByPattern[parentPath] = append(fieldsByPattern[parentPath], fieldName)
84+
if !slices.Contains(fieldsByPattern[parentPath], fieldName) {
85+
fieldsByPattern[parentPath] = append(fieldsByPattern[parentPath], fieldName)
86+
}
8387
return true
8488
})
8589

0 commit comments

Comments
 (0)