Skip to content

Conversation

@cesco-f
Copy link
Contributor

@cesco-f cesco-f commented Nov 25, 2025

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 #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:

Screen.Recording.2025-11-25.at.11.51.52.mov

After:

Screen.Recording.2025-11-25.at.11.50.48.mov

@cesco-f cesco-f requested a review from a team as a code owner November 25, 2025 10:57
@cesco-f cesco-f added release_note:fix backport:version Backport to applied version labels v9.2.2 labels Nov 25, 2025
@github-actions github-actions bot added the author:actionable-obs PRs authored by the actionable obs team label Nov 25, 2025
@cesco-f cesco-f changed the title [Rule params] Added managed to dataViewSpecSchema [Rule params] Added managed field to dataViewSpecSchema Nov 25, 2025
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner November 25, 2025 11:18
@github-actions
Copy link
Contributor

@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.

@cesco-f cesco-f removed the request for review from a team November 25, 2025 13:59
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner November 25, 2025 14:20
@cesco-f cesco-f requested a review from a team as a code owner November 25, 2025 14:28
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@cesco-f cesco-f removed the request for review from a team November 25, 2025 14:29
@cesco-f cesco-f changed the title [Rule params] Added managed field to dataViewSpecSchema [Rule params] Remove unnecessary managed field from custom threshold rule params Nov 25, 2025
@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label Nov 25, 2025
@github-actions
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@cesco-f cesco-f marked this pull request as draft November 26, 2025 08:13
@cesco-f cesco-f changed the title [Rule params] Remove unnecessary managed field from custom threshold rule params [Rule params] Make dataViewSpecSchema resilient to unknown properties Nov 26, 2025
@cesco-f cesco-f marked this pull request as ready for review November 26, 2025 08:56
@cesco-f cesco-f requested a review from a team November 26, 2025 09:02
Comment on lines 184 to 190
{
// 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',
}
);
Copy link
Contributor Author

@cesco-f cesco-f Nov 26, 2025

Choose a reason for hiding this comment

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

I'd like to have feedback from @elastic/response-ops about this if possible. @cnasikas @jcger

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Member

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.)

Copy link
Contributor

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)

Copy link
Contributor Author

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

@cesco-f cesco-f changed the title [Rule params] Make dataViewSpecSchema resilient to unknown properties [Rule params] Add managed field to dataViewSpecSchema Nov 27, 2025
@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 27, 2025

💛 Build succeeded, but was flaky

  • Buildkite Build
  • Commit: e7d5d6b
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-244134-e7d5d6bf045f

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #119 / discover/tabs tabs saving and loading time based tabs should not show time range switch when saving if no tab is time based

Metrics [docs]

✅ unchanged

History

Copy link
Contributor

@miguelmartin-elastic miguelmartin-elastic left a comment

Choose a reason for hiding this comment

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

lgtm!

@cesco-f cesco-f merged commit f6abc44 into elastic:main Nov 28, 2025
13 checks passed
@cesco-f cesco-f deleted the fix-rule-params branch November 28, 2025 12:34
@kibanamachine
Copy link
Contributor

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Nov 28, 2025
## 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)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
9.2

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 28, 2025
…#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]>
tkajtoch pushed a commit to tkajtoch/kibana that referenced this pull request Dec 1, 2025
## 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]>
NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Dec 2, 2025
## 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]>
@mistic mistic added v9.2.3 and removed v9.2.2 labels Dec 3, 2025
JordanSh pushed a commit to JordanSh/kibana that referenced this pull request Dec 9, 2025
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:actionable-obs PRs authored by the actionable obs team backport:version Backport to applied version labels ci:project-deploy-observability Create an Observability project release_note:fix Team:obs-ux-management v9.2.3 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants