-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Rule params] Add managed field to dataViewSpecSchema #244134
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
Conversation
managed field to dataViewSpecSchema
|
@cesco-f, it looks like you're updating the parameters for a rule type! Please review the guidelines for making additive changes to rule type parameters and determine if your changes require an intermediate release. |
|
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
managed field to dataViewSpecSchemamanaged field from custom threshold rule params
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
managed field from custom threshold rule params| { | ||
| // Allow and ignore unknown properties to make the schema resilient to new properties | ||
| // added by the data-views plugin (e.g. 'managed'). This prevents validation errors | ||
| // when the DataViewSpec type is extended but our schema hasn't been updated yet. | ||
| unknowns: 'ignore', | ||
| } | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you alternatively add that field as a maybe to pass validation and then just ignore it? That would be a less impactful change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that if I do that and more fields are added to the Data view I'll face the exact same problem. I'd like a more resilient solution for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that we don't validate searchConfigruation parameters in ES Query rule? (code)
If that’s the case, the change Francesco introduced would be more future-proof, but perhaps not ideal. It would be better if API validation came from the data-plugin itself, so that if the schema changes in the future, we still get the correct validation. (Bonus: Would be great to avoid storing everything as-is in the rule and instead define a separate schema specifically for API persistence.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that we don't validate searchConfigruation parameters in ES Query rule? (code)
It seems like it 🤔
The thing is that if I do that and more fields are added to the Data view I'll face the exact same problem. I'd like a more resilient solution for this.
Agree, but that would be at the expense of things like misconfigured rules where typos get ignored, and the user doesn't know it is running incorrectly. Also, as soon as we toggle that option, removing it will become a breaking change.
imo it's better to allow the minimum possible bit by bit, rather than everything all at once.
It would be better if API validation came from the data-plugin itself, so that if the schema changes in the future, we still get the correct validation.
+1, I will discuss it with the team! (But not for this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, but that would be at the expense of things like misconfigured rules where typos get ignored, and the user doesn't know it is running incorrectly. Also, as soon as we toggle that option, removing it will become a breaking change.
imo it's better to allow the minimum possible bit by bit, rather than everything all at once.
Changed it here: e76448b
...solutions/observability/test/observability_functional/apps/observability/pages/rules_page.ts
Outdated
Show resolved
Hide resolved
db4c5b3 to
e76448b
Compare
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
miguelmartin-elastic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
|
Starting backport for target branches: 9.2 |
## Summary Fixes validation error when creating custom threshold rules with data view objects by adding the missing `managed` field to `dataViewSpecSchema`. ## Problem When creating a custom threshold rule with a data view object in `searchConfiguration.index`, the validation was failing with: `params invalid: [searchConfiguration.index]: types that failed validation: [searchConfiguration.index.0]: expected value of type [string] but got [Object] [searchConfiguration.index.1.managed]: definition for this key is missing` The DataView's `toSpec()` method includes a `managed` field (added in elastic#223451), but this field was not part of the `dataViewSpecSchema` validation, causing rule creation to fail. ## Solution Added the `managed` field as an optional boolean to `dataViewSpecSchema` in `@kbn/response-ops-rule-params`. `managed: schema.maybe(schema.boolean())` This approach explicitly defines the expected field rather than ignoring unknown properties, which: - Maintains strict validation (typos/misconfigured rules will still fail) - Avoids the breaking change implications of toggling `unknowns: 'ignore'` Before: https://github.com/user-attachments/assets/7ad0fd02-9dc6-42fe-b90c-bf87d73cca9d After: https://github.com/user-attachments/assets/385eb375-ac9d-471c-8a2f-118f1e56dd74 --------- Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit f6abc44)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…#244640) # Backport This will backport the following commits from `main` to `9.2`: - [[Rule params] Add managed field to dataViewSpecSchema (#244134)](#244134) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Francesco Fagnani","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-11-28T12:34:51Z","message":"[Rule params] Add managed field to dataViewSpecSchema (#244134)\n\n## Summary\n\nFixes validation error when creating custom threshold rules with data\nview objects by adding the missing `managed` field to\n`dataViewSpecSchema`.\n\n## Problem\n\nWhen creating a custom threshold rule with a data view object in\n`searchConfiguration.index`, the validation was failing with:\n\n`params invalid: [searchConfiguration.index]: types that failed\nvalidation:\n[searchConfiguration.index.0]: expected value of type [string] but got\n[Object]\n[searchConfiguration.index.1.managed]: definition for this key is\nmissing`\n\nThe DataView's `toSpec()` method includes a `managed` field (added in\n#223451), but this field was not part of the `dataViewSpecSchema`\nvalidation, causing rule creation to fail.\n\n## Solution\n\nAdded the `managed` field as an optional boolean to `dataViewSpecSchema`\nin `@kbn/response-ops-rule-params`.\n\n`managed: schema.maybe(schema.boolean())`\n\nThis approach explicitly defines the expected field rather than ignoring\nunknown properties, which:\n- Maintains strict validation (typos/misconfigured rules will still\nfail)\n- Avoids the breaking change implications of toggling `unknowns:\n'ignore'`\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/7ad0fd02-9dc6-42fe-b90c-bf87d73cca9d\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/385eb375-ac9d-471c-8a2f-118f1e56dd74\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"f6abc4444d3849f212f715cfeb0d5187b25bf6c5","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","ci:project-deploy-observability","backport:version","v9.3.0","v9.2.2","author:actionable-obs","Team:obs-ux-management"],"title":"[Rule params] Add managed field to dataViewSpecSchema","number":244134,"url":"https://github.com/elastic/kibana/pull/244134","mergeCommit":{"message":"[Rule params] Add managed field to dataViewSpecSchema (#244134)\n\n## Summary\n\nFixes validation error when creating custom threshold rules with data\nview objects by adding the missing `managed` field to\n`dataViewSpecSchema`.\n\n## Problem\n\nWhen creating a custom threshold rule with a data view object in\n`searchConfiguration.index`, the validation was failing with:\n\n`params invalid: [searchConfiguration.index]: types that failed\nvalidation:\n[searchConfiguration.index.0]: expected value of type [string] but got\n[Object]\n[searchConfiguration.index.1.managed]: definition for this key is\nmissing`\n\nThe DataView's `toSpec()` method includes a `managed` field (added in\n#223451), but this field was not part of the `dataViewSpecSchema`\nvalidation, causing rule creation to fail.\n\n## Solution\n\nAdded the `managed` field as an optional boolean to `dataViewSpecSchema`\nin `@kbn/response-ops-rule-params`.\n\n`managed: schema.maybe(schema.boolean())`\n\nThis approach explicitly defines the expected field rather than ignoring\nunknown properties, which:\n- Maintains strict validation (typos/misconfigured rules will still\nfail)\n- Avoids the breaking change implications of toggling `unknowns:\n'ignore'`\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/7ad0fd02-9dc6-42fe-b90c-bf87d73cca9d\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/385eb375-ac9d-471c-8a2f-118f1e56dd74\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"f6abc4444d3849f212f715cfeb0d5187b25bf6c5"}},"sourceBranch":"main","suggestedTargetBranches":["9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/244134","number":244134,"mergeCommit":{"message":"[Rule params] Add managed field to dataViewSpecSchema (#244134)\n\n## Summary\n\nFixes validation error when creating custom threshold rules with data\nview objects by adding the missing `managed` field to\n`dataViewSpecSchema`.\n\n## Problem\n\nWhen creating a custom threshold rule with a data view object in\n`searchConfiguration.index`, the validation was failing with:\n\n`params invalid: [searchConfiguration.index]: types that failed\nvalidation:\n[searchConfiguration.index.0]: expected value of type [string] but got\n[Object]\n[searchConfiguration.index.1.managed]: definition for this key is\nmissing`\n\nThe DataView's `toSpec()` method includes a `managed` field (added in\n#223451), but this field was not part of the `dataViewSpecSchema`\nvalidation, causing rule creation to fail.\n\n## Solution\n\nAdded the `managed` field as an optional boolean to `dataViewSpecSchema`\nin `@kbn/response-ops-rule-params`.\n\n`managed: schema.maybe(schema.boolean())`\n\nThis approach explicitly defines the expected field rather than ignoring\nunknown properties, which:\n- Maintains strict validation (typos/misconfigured rules will still\nfail)\n- Avoids the breaking change implications of toggling `unknowns:\n'ignore'`\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/7ad0fd02-9dc6-42fe-b90c-bf87d73cca9d\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/385eb375-ac9d-471c-8a2f-118f1e56dd74\n\n---------\n\nCo-authored-by: kibanamachine <[email protected]>","sha":"f6abc4444d3849f212f715cfeb0d5187b25bf6c5"}},{"branch":"9.2","label":"v9.2.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Francesco Fagnani <[email protected]>
## Summary Fixes validation error when creating custom threshold rules with data view objects by adding the missing `managed` field to `dataViewSpecSchema`. ## Problem When creating a custom threshold rule with a data view object in `searchConfiguration.index`, the validation was failing with: `params invalid: [searchConfiguration.index]: types that failed validation: [searchConfiguration.index.0]: expected value of type [string] but got [Object] [searchConfiguration.index.1.managed]: definition for this key is missing` The DataView's `toSpec()` method includes a `managed` field (added in elastic#223451), but this field was not part of the `dataViewSpecSchema` validation, causing rule creation to fail. ## Solution Added the `managed` field as an optional boolean to `dataViewSpecSchema` in `@kbn/response-ops-rule-params`. `managed: schema.maybe(schema.boolean())` This approach explicitly defines the expected field rather than ignoring unknown properties, which: - Maintains strict validation (typos/misconfigured rules will still fail) - Avoids the breaking change implications of toggling `unknowns: 'ignore'` Before: https://github.com/user-attachments/assets/7ad0fd02-9dc6-42fe-b90c-bf87d73cca9d After: https://github.com/user-attachments/assets/385eb375-ac9d-471c-8a2f-118f1e56dd74 --------- Co-authored-by: kibanamachine <[email protected]>
## Summary Fixes validation error when creating custom threshold rules with data view objects by adding the missing `managed` field to `dataViewSpecSchema`. ## Problem When creating a custom threshold rule with a data view object in `searchConfiguration.index`, the validation was failing with: `params invalid: [searchConfiguration.index]: types that failed validation: [searchConfiguration.index.0]: expected value of type [string] but got [Object] [searchConfiguration.index.1.managed]: definition for this key is missing` The DataView's `toSpec()` method includes a `managed` field (added in elastic#223451), but this field was not part of the `dataViewSpecSchema` validation, causing rule creation to fail. ## Solution Added the `managed` field as an optional boolean to `dataViewSpecSchema` in `@kbn/response-ops-rule-params`. `managed: schema.maybe(schema.boolean())` This approach explicitly defines the expected field rather than ignoring unknown properties, which: - Maintains strict validation (typos/misconfigured rules will still fail) - Avoids the breaking change implications of toggling `unknowns: 'ignore'` Before: https://github.com/user-attachments/assets/7ad0fd02-9dc6-42fe-b90c-bf87d73cca9d After: https://github.com/user-attachments/assets/385eb375-ac9d-471c-8a2f-118f1e56dd74 --------- Co-authored-by: kibanamachine <[email protected]>
## Summary Fixes validation error when creating custom threshold rules with data view objects by adding the missing `managed` field to `dataViewSpecSchema`. ## Problem When creating a custom threshold rule with a data view object in `searchConfiguration.index`, the validation was failing with: `params invalid: [searchConfiguration.index]: types that failed validation: [searchConfiguration.index.0]: expected value of type [string] but got [Object] [searchConfiguration.index.1.managed]: definition for this key is missing` The DataView's `toSpec()` method includes a `managed` field (added in elastic#223451), but this field was not part of the `dataViewSpecSchema` validation, causing rule creation to fail. ## Solution Added the `managed` field as an optional boolean to `dataViewSpecSchema` in `@kbn/response-ops-rule-params`. `managed: schema.maybe(schema.boolean())` This approach explicitly defines the expected field rather than ignoring unknown properties, which: - Maintains strict validation (typos/misconfigured rules will still fail) - Avoids the breaking change implications of toggling `unknowns: 'ignore'` Before: https://github.com/user-attachments/assets/7ad0fd02-9dc6-42fe-b90c-bf87d73cca9d After: https://github.com/user-attachments/assets/385eb375-ac9d-471c-8a2f-118f1e56dd74 --------- Co-authored-by: kibanamachine <[email protected]>
Summary
Fixes validation error when creating custom threshold rules with data view objects by adding the missing
managedfield todataViewSpecSchema.Problem
When creating a custom threshold rule with a data view object in
searchConfiguration.index, the validation was failing with:params invalid: [searchConfiguration.index]: types that failed validation: [searchConfiguration.index.0]: expected value of type [string] but got [Object] [searchConfiguration.index.1.managed]: definition for this key is missingThe DataView's
toSpec()method includes amanagedfield (added in #223451), but this field was not part of thedataViewSpecSchemavalidation, causing rule creation to fail.Solution
Added the
managedfield as an optional boolean todataViewSpecSchemain@kbn/response-ops-rule-params.managed: schema.maybe(schema.boolean())This approach explicitly defines the expected field rather than ignoring unknown properties, which:
unknowns: 'ignore'Before:
Screen.Recording.2025-11-25.at.11.51.52.mov
After:
Screen.Recording.2025-11-25.at.11.50.48.mov