Skip to content

[SavedObjects] Allow schema-only changes in the latest model version without a version bump#256432

Merged
gsoldevila merged 2 commits intoelastic:mainfrom
gsoldevila:cps-so-schema-only-change
Mar 11, 2026
Merged

[SavedObjects] Allow schema-only changes in the latest model version without a version bump#256432
gsoldevila merged 2 commits intoelastic:mainfrom
gsoldevila:cps-so-schema-only-change

Conversation

@gsoldevila
Copy link
Copy Markdown
Member

Summary

When a saved object type's schema validation constraints are tightened (e.g. adding a maxSize limit to an array field) without touching the underlying ES mappings, the 'Check changes in Saved Objects' CI check was incorrectly rejecting the change as a forbidden model version mutation.

This PR relaxes the validation to allow schema-only changes to the latest model version, provided all three conditions hold:

  • Only the latest model version's schemas were modified (no older versions touched).
  • The mappings have not been modified.
  • The latest model version's schema still covers all mapped fields (validateAllMappingsInModelVersion still passes).

When this exceptional case is detected, a warning is emitted in the CI output making it clear why the change is allowed and reminding that any future mapping changes will still require a proper model version bump.

Context

Fixes the CI failure on #255741, where adding a maxSize constraint to the tags field in the security-rule SO type caused the check to fail.

Tracking task: https://github.com/elastic/kibana-team/issues/3021 (sub-issue of https://github.com/elastic/kibana-team/issues/2349)

Made with Cursor

@gsoldevila gsoldevila added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting labels Mar 6, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 6, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (4)
  • reviewer:coderabbit
  • Team:Search
  • Team:Operations
  • Team:QA

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 3c44e870-0ba6-4201-8fa0-9a512617daab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@gsoldevila gsoldevila marked this pull request as ready for review March 9, 2026 11:17
@gsoldevila gsoldevila requested a review from a team as a code owner March 9, 2026 11:17
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-core (Team:Core)

@gsoldevila
Copy link
Copy Markdown
Member Author

/ci-ralph

@gsoldevila
Copy link
Copy Markdown
Member Author

/ralph check the test failures of build 406651 and fix them

Build URL: https://buildkite.com/elastic/kibana-pull-request/builds/406651

Use ci/bk-build-info.sh 406651 to fetch detailed build failure information.

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Scout: [ platform / spaces ] plugin / local-serverless-security_complete - Spaces selection - as Admin - displays the space selection menu in header

Metrics [docs]

✅ unchanged

History

to: ctx.to?.typeDefinitions[name]!,
from: ctx.from!.typeDefinitions[type.name],
to: ctx.to?.typeDefinitions[type.name]!,
registeredType: type,
Copy link
Copy Markdown
Contributor

@hammad-nasir-elastic hammad-nasir-elastic Mar 10, 2026

Choose a reason for hiding this comment

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

Should registeredType and log also be included in validate_updated_types.ts as part of the recently merged serverless baseline check to prevent schema only changes failing against the serverless baseline?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Makes total sense, good catch! I totally forgot about your in-flight PR.

const to = loadSnapshot('schema_only_change_in_latest_model_version_updated.json');
const log = jest.fn();

expect(() => validateChangesWrapper({ from, to, name: 'task', log })).not.toThrow();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I noticed that registeredType isn’t being passed, and I’m wondering whether we should pass a mock registeredType to exercise the validateAllMappingsInModelVersion path that I believe would cover the scenario where there’s a schema only change but the schema doesn’t cover all mapped fields resulting in a throw.

Copy link
Copy Markdown
Contributor

@hammad-nasir-elastic hammad-nasir-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 overall! Just had 2 questions but will unblock for any progress/updates.

…without a version bump

When a saved object type's schema validation constraints are tightened (e.g. adding a
maxSize limit) without touching the ES mappings, the CI check was incorrectly rejecting
the change as a model version mutation.

Schema-only changes to the LATEST model version are now allowed when:
- No older model versions were mutated.
- The mappings have not been modified.
- The latest model version's schema still covers all mapped fields.

A warning is emitted in this case to make the exceptional nature of the allowance explicit.

Closes: elastic/kibana-team#3021
Made-with: Cursor
@gsoldevila gsoldevila force-pushed the cps-so-schema-only-change branch from d1471e0 to 0f3f585 Compare March 11, 2026 12:27
@gsoldevila gsoldevila enabled auto-merge (squash) March 11, 2026 12:29
@gsoldevila gsoldevila merged commit 80b433d into elastic:main Mar 11, 2026
18 checks passed
sorenlouv pushed a commit that referenced this pull request Mar 17, 2026
…without a version bump (#256432)

## Summary

When a saved object type's schema validation constraints are tightened
(e.g. adding a `maxSize` limit to an array field) without touching the
underlying ES mappings, the 'Check changes in Saved Objects' CI check
was incorrectly rejecting the change as a forbidden model version
mutation.

This PR relaxes the validation to allow schema-only changes to the
**latest** model version, provided all three conditions hold:
- Only the latest model version's schemas were modified (no older
versions touched).
- The mappings have not been modified.
- The latest model version's schema still covers all mapped fields
(`validateAllMappingsInModelVersion` still passes).

When this exceptional case is detected, a warning is emitted in the CI
output making it clear why the change is allowed and reminding that any
future mapping changes will still require a proper model version bump.

## Context

Fixes the CI failure on #255741,
where adding a `maxSize` constraint to the `tags` field in the
`security-rule` SO type caused the check to fail.

Tracking task: https://github.com/elastic/kibana-team/issues/3021
(sub-issue of https://github.com/elastic/kibana-team/issues/2349)

Made with [Cursor](https://cursor.com)
jeramysoucy pushed a commit to jeramysoucy/kibana that referenced this pull request Mar 26, 2026
…without a version bump (elastic#256432)

## Summary

When a saved object type's schema validation constraints are tightened
(e.g. adding a `maxSize` limit to an array field) without touching the
underlying ES mappings, the 'Check changes in Saved Objects' CI check
was incorrectly rejecting the change as a forbidden model version
mutation.

This PR relaxes the validation to allow schema-only changes to the
**latest** model version, provided all three conditions hold:
- Only the latest model version's schemas were modified (no older
versions touched).
- The mappings have not been modified.
- The latest model version's schema still covers all mapped fields
(`validateAllMappingsInModelVersion` still passes).

When this exceptional case is detected, a warning is emitted in the CI
output making it clear why the change is allowed and reminding that any
future mapping changes will still require a proper model version bump.

## Context

Fixes the CI failure on elastic#255741,
where adding a `maxSize` constraint to the `tags` field in the
`security-rule` SO type caused the check to fail.

Tracking task: elastic/kibana-team#3021
(sub-issue of elastic/kibana-team#2349)

Made with [Cursor](https://cursor.com)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants