[SavedObjects] Allow schema-only changes in the latest model version without a version bump#256432
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (4)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
|
Pinging @elastic/kibana-core (Team:Core) |
|
/ci-ralph |
|
/ralph check the test failures of build 406651 and fix them Build URL: https://buildkite.com/elastic/kibana-pull-request/builds/406651 Use |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
| to: ctx.to?.typeDefinitions[name]!, | ||
| from: ctx.from!.typeDefinitions[type.name], | ||
| to: ctx.to?.typeDefinitions[type.name]!, | ||
| registeredType: type, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
hammad-nasir-elastic
left a comment
There was a problem hiding this comment.
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
d1471e0 to
0f3f585
Compare
…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)
…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)
Summary
When a saved object type's schema validation constraints are tightened (e.g. adding a
maxSizelimit 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:
validateAllMappingsInModelVersionstill 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
maxSizeconstraint to thetagsfield in thesecurity-ruleSO 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