You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Based on discussion from community, when uploading rules view the CLI command, it references the JSONschema which is a frozen state of the NewTermsRuleData schema.
In the NewTermsRuleData class there is a method called transform which is called if it exists from _post_dict_conversion. This method, for NewTermsRuleData specifically adjusted the JSON object of the New Terms rule so that new_terms becomes new_terms_fields and sits in the root of the JSON object. This is the expected format of the rule object for the Kibana API.
The reason the schema was developed this way was based on how rule types and schemas are identified by the rule loader, which will attempt to find new_terms which is what type is set to in a TOML rule.
Since the JSONSchema is frozen based on the NewTermsRuleData when it attempts to validate the API object of the rule, the fields are not matching and thus causes issues when jsonschema.validate() is called during strip_additional_properties which is used when attempting to upload rules from CLI.
defstrip_additional_properties(version: Version, api_contents: dict) ->dict:
"""Remove all fields that the target schema doesn't recognize."""ifVersion.parse(version, optional_minor_and_patch=True) >=Version.parse("8.3.0"):
api_contents=strip_build_time_fields(api_contents)
stripped= {}
target_schema=get_schema_file(version, api_contents["type"])
forfield, field_schemaintarget_schema["properties"].items():
iffieldinapi_contents:
stripped[field] =api_contents[field]
# finally, validate against the json schemajsonschema.validate(stripped, target_schema)
returnstripped
To Reproduce
Go to an old branch in our repo
Use a later stack version than the repo selected
Run the upload-rule command
See that any new terms rule either error or have been removed from the upload because of jsonschema validation
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Based on discussion from community, when uploading rules view the CLI command, it references the
JSONschema
which is a frozen state of theNewTermsRuleData
schema.In the
NewTermsRuleData
class there is a method calledtransform
which is called if it exists from_post_dict_conversion
. This method, forNewTermsRuleData
specifically adjusted the JSON object of the New Terms rule so thatnew_terms
becomesnew_terms_fields
and sits in the root of the JSON object. This is the expected format of the rule object for the Kibana API.The reason the schema was developed this way was based on how rule types and schemas are identified by the rule loader, which will attempt to find
new_terms
which is whattype
is set to in a TOML rule.Since the
JSONSchema
is frozen based on theNewTermsRuleData
when it attempts to validate the API object of the rule, the fields are not matching and thus causes issues whenjsonschema.validate()
is called duringstrip_additional_properties
which is used when attempting to upload rules from CLI.To Reproduce
upload-rule
commandnew terms
rule either error or have been removed from the upload because of jsonschema validationAdditional Information
Please see #2360
The text was updated successfully, but these errors were encountered: