Skip to content
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

[server-route-repository] Only validate zod schemas in dev mode #210412

Merged

Conversation

miltonhultgren
Copy link
Contributor

@miltonhultgren miltonhultgren commented Feb 10, 2025

In #208166, we added a validation step that verifies that all zod schemas:
a) Are built with supported types, meaning types that we can analyze for if they are applied strictly (no excess keys)
b) Are built with any side effects (refine or transform, which may impact the type reliability)

This doesn't impact the actual parameter validation, but is instead an additional check on the schemas we're using.
For any violation found, we log a warning, this has the downside of increasing our total log volume and is only really needed in development mode.

Hence, in this PR, we're only logging these warnings if Kibana is running in dev mode, and the PR updates all consuming plugins to pass this context along.

@miltonhultgren miltonhultgren requested review from a team as code owners February 10, 2025 16:06
@botelastic botelastic bot added Team:Obs AI Assistant Observability AI Assistant Team:obs-ux-management Observability Management User Experience Team labels Feb 10, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@elasticmachine
Copy link
Contributor

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

@miltonhultgren miltonhultgren added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v8.19.0 v9.1.0 labels Feb 10, 2025
Copy link
Contributor

@rmyz rmyz left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

I added a comment to improve the name of this field. :)

Copy link
Contributor

@awahab07 awahab07 left a comment

Choose a reason for hiding this comment

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

LGTM!

@miltonhultgren miltonhultgren enabled auto-merge (squash) February 11, 2025 11:11
@miltonhultgren miltonhultgren merged commit 42f5b0b into elastic:main Feb 12, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.x, 9.0

https://github.com/elastic/kibana/actions/runs/13284322858

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/server-route-repository 39 40 +1
Unknown metric groups

API count

id before after diff
@kbn/server-route-repository 39 40 +1

History

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 12, 2025
elastic#210412)

In elastic#208166, we added a validation
step that verifies that all zod schemas:
a) Are built with supported types, meaning types that we can analyze for
if they are applied strictly (no excess keys)
b) Are built with any side effects (refine or transform, which may
impact the type reliability)

This doesn't impact the actual parameter validation, but is instead an
additional check on the schemas we're using.
For any violation found, we log a warning, this has the downside of
increasing our total log volume and is only really needed in development
mode.

Hence, in this PR, we're only logging these warnings if Kibana is
running in dev mode, and the PR updates all consuming plugins to pass
this context along.

(cherry picked from commit 42f5b0b)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 12, 2025
elastic#210412)

In elastic#208166, we added a validation
step that verifies that all zod schemas:
a) Are built with supported types, meaning types that we can analyze for
if they are applied strictly (no excess keys)
b) Are built with any side effects (refine or transform, which may
impact the type reliability)

This doesn't impact the actual parameter validation, but is instead an
additional check on the schemas we're using.
For any violation found, we log a warning, this has the downside of
increasing our total log volume and is only really needed in development
mode.

Hence, in this PR, we're only logging these warnings if Kibana is
running in dev mode, and the PR updates all consuming plugins to pass
this context along.

(cherry picked from commit 42f5b0b)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.18
8.x Backport failed because of merge conflicts
9.0

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 210412

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 12, 2025
…ev mode (#210412) (#210795)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[server-route-repository] Only validate zod schema effects in dev
mode (#210412)](#210412)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Milton
Hultgren","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-12T11:28:10Z","message":"[server-route-repository]
Only validate zod schema effects in dev mode (#210412)\n\nIn
#208166, we added a
validation\r\nstep that verifies that all zod schemas:\r\na) Are built
with supported types, meaning types that we can analyze for\r\nif they
are applied strictly (no excess keys)\r\nb) Are built with any side
effects (refine or transform, which may\r\nimpact the type
reliability)\r\n\r\nThis doesn't impact the actual parameter validation,
but is instead an\r\nadditional check on the schemas we're using.\r\nFor
any violation found, we log a warning, this has the downside
of\r\nincreasing our total log volume and is only really needed in
development\r\nmode.\r\n\r\nHence, in this PR, we're only logging these
warnings if Kibana is\r\nrunning in dev mode, and the PR updates all
consuming plugins to pass\r\nthis context
along.","sha":"42f5b0ba170e49db54e0aef5d56e255659484365","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Obs
AI
Assistant","Team:obs-ux-management","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[server-route-repository]
Only validate zod schemas in dev
mode","number":210412,"url":"https://github.com/elastic/kibana/pull/210412","mergeCommit":{"message":"[server-route-repository]
Only validate zod schema effects in dev mode (#210412)\n\nIn
#208166, we added a
validation\r\nstep that verifies that all zod schemas:\r\na) Are built
with supported types, meaning types that we can analyze for\r\nif they
are applied strictly (no excess keys)\r\nb) Are built with any side
effects (refine or transform, which may\r\nimpact the type
reliability)\r\n\r\nThis doesn't impact the actual parameter validation,
but is instead an\r\nadditional check on the schemas we're using.\r\nFor
any violation found, we log a warning, this has the downside
of\r\nincreasing our total log volume and is only really needed in
development\r\nmode.\r\n\r\nHence, in this PR, we're only logging these
warnings if Kibana is\r\nrunning in dev mode, and the PR updates all
consuming plugins to pass\r\nthis context
along.","sha":"42f5b0ba170e49db54e0aef5d56e255659484365"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210412","number":210412,"mergeCommit":{"message":"[server-route-repository]
Only validate zod schema effects in dev mode (#210412)\n\nIn
#208166, we added a
validation\r\nstep that verifies that all zod schemas:\r\na) Are built
with supported types, meaning types that we can analyze for\r\nif they
are applied strictly (no excess keys)\r\nb) Are built with any side
effects (refine or transform, which may\r\nimpact the type
reliability)\r\n\r\nThis doesn't impact the actual parameter validation,
but is instead an\r\nadditional check on the schemas we're using.\r\nFor
any violation found, we log a warning, this has the downside
of\r\nincreasing our total log volume and is only really needed in
development\r\nmode.\r\n\r\nHence, in this PR, we're only logging these
warnings if Kibana is\r\nrunning in dev mode, and the PR updates all
consuming plugins to pass\r\nthis context
along.","sha":"42f5b0ba170e49db54e0aef5d56e255659484365"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Milton Hultgren <[email protected]>
kibanamachine added a commit that referenced this pull request Feb 12, 2025
…dev mode (#210412) (#210794)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[server-route-repository] Only validate zod schema effects in dev
mode (#210412)](#210412)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Milton
Hultgren","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-12T11:28:10Z","message":"[server-route-repository]
Only validate zod schema effects in dev mode (#210412)\n\nIn
#208166, we added a
validation\r\nstep that verifies that all zod schemas:\r\na) Are built
with supported types, meaning types that we can analyze for\r\nif they
are applied strictly (no excess keys)\r\nb) Are built with any side
effects (refine or transform, which may\r\nimpact the type
reliability)\r\n\r\nThis doesn't impact the actual parameter validation,
but is instead an\r\nadditional check on the schemas we're using.\r\nFor
any violation found, we log a warning, this has the downside
of\r\nincreasing our total log volume and is only really needed in
development\r\nmode.\r\n\r\nHence, in this PR, we're only logging these
warnings if Kibana is\r\nrunning in dev mode, and the PR updates all
consuming plugins to pass\r\nthis context
along.","sha":"42f5b0ba170e49db54e0aef5d56e255659484365","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Obs
AI
Assistant","Team:obs-ux-management","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[server-route-repository]
Only validate zod schemas in dev
mode","number":210412,"url":"https://github.com/elastic/kibana/pull/210412","mergeCommit":{"message":"[server-route-repository]
Only validate zod schema effects in dev mode (#210412)\n\nIn
#208166, we added a
validation\r\nstep that verifies that all zod schemas:\r\na) Are built
with supported types, meaning types that we can analyze for\r\nif they
are applied strictly (no excess keys)\r\nb) Are built with any side
effects (refine or transform, which may\r\nimpact the type
reliability)\r\n\r\nThis doesn't impact the actual parameter validation,
but is instead an\r\nadditional check on the schemas we're using.\r\nFor
any violation found, we log a warning, this has the downside
of\r\nincreasing our total log volume and is only really needed in
development\r\nmode.\r\n\r\nHence, in this PR, we're only logging these
warnings if Kibana is\r\nrunning in dev mode, and the PR updates all
consuming plugins to pass\r\nthis context
along.","sha":"42f5b0ba170e49db54e0aef5d56e255659484365"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210412","number":210412,"mergeCommit":{"message":"[server-route-repository]
Only validate zod schema effects in dev mode (#210412)\n\nIn
#208166, we added a
validation\r\nstep that verifies that all zod schemas:\r\na) Are built
with supported types, meaning types that we can analyze for\r\nif they
are applied strictly (no excess keys)\r\nb) Are built with any side
effects (refine or transform, which may\r\nimpact the type
reliability)\r\n\r\nThis doesn't impact the actual parameter validation,
but is instead an\r\nadditional check on the schemas we're using.\r\nFor
any violation found, we log a warning, this has the downside
of\r\nincreasing our total log volume and is only really needed in
development\r\nmode.\r\n\r\nHence, in this PR, we're only logging these
warnings if Kibana is\r\nrunning in dev mode, and the PR updates all
consuming plugins to pass\r\nthis context
along.","sha":"42f5b0ba170e49db54e0aef5d56e255659484365"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Milton Hultgren <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Obs AI Assistant Observability AI Assistant Team:obs-ux-management Observability Management User Experience Team v8.18.0 v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants