Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require type group or nested for fields with subfields #629

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/go/pkg/validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func TestValidateFile(t *testing.T) {
`field 0.type: 0.type must be one of the following: "aggregate_metric_double", "alias", "histogram", "constant_keyword", "text", "match_only_text", "keyword", "long", "integer", "short", "byte", "double", "float", "half_float", "scaled_float", "date", "date_nanos", "boolean", "binary", "integer_range", "float_range", "long_range", "double_range", "date_range", "ip_range", "group", "geo_point", "object", "ip", "nested", "flattened", "wildcard", "version", "unsigned_long"`,
`field "my_custom_date" of type keyword can't set date_format. date_format is allowed for date field type only`,
`field 2: object_type is required`,
`field 3.type: 3.type must be one of the following: "group", "nested"`,
},
},
"deploy_custom_agent_invalid_property": {
Expand Down
3 changes: 3 additions & 0 deletions spec/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
- description: Update import paths for Go code
type: breaking-change
link: https://github.com/elastic/package-spec/issues/626
- description: Require group or nested types for fields with subobjects
type: bugfix
link: https://github.com/elastic/package-spec/pull/629
- version: 2.13.0
changes:
- description: Allow to define expected values in fields definitions.
Expand Down
16 changes: 15 additions & 1 deletion spec/integration/data_stream/fields/fields.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,18 @@ spec:
then:
required:
- object_type
- if:
properties:
fields:
minContent: 1
required:
- fields
then:
properties:
type:
enum:
- group
- nested

required:
- name
Expand All @@ -542,7 +554,9 @@ versions:
- before: 3.0.0
patch:
- op: remove
path: "/items/allOf/6" # removing requirement of object_type when type is object
path: "/items/allOf/7" # removing requirement of type group when element has subfields
- op: remove
path: "/items/allOf/6" # removing requirement of object_type and minimum fields when type is object
- before: 2.10.0
patch:
- op: remove
Expand Down
7 changes: 7 additions & 0 deletions test/packages/bad_fields/data_stream/foo/fields/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@
date_format: yyyy-MM-dd
- name: object_without_object_type.*
type: object
- name: object_with_subfields
description: This field should be of type group, because it contains subfields.
type: object
object_type: keyword
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object_type is not necessary here, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it wouldn't be neccesary to produce this validation error, but I added it so it doesn't trigger also the error about missing object_type for object.

fields:
- name: foo
type: keyword