Skip to content

[Fleet] Fix SimplifiedVarsSchema coercing string "true"/"false" to boolean#256047

Merged
nchaulet merged 2 commits intomainfrom
fix-255976-simplified-policy-variable-boolean-coerce
Mar 4, 2026
Merged

[Fleet] Fix SimplifiedVarsSchema coercing string "true"/"false" to boolean#256047
nchaulet merged 2 commits intomainfrom
fix-255976-simplified-policy-variable-boolean-coerce

Conversation

@nchaulet
Copy link
Copy Markdown
Member

@nchaulet nchaulet commented Mar 4, 2026

Description

Resolve #255976

Fix SimplifiedVarsSchema coercing string variable values like "true" and "false" to booleans.

The schema.oneOf validator matches the first passing schema in order. Previously schema.boolean() came before schema.string(), causing string values of "true"/"false" to be coerced to boolean true/false. This reorders the validators so schema.string() is tried first.

Tests

Added unit tests for SimplifiedVarsSchema

You can try to use the package policy API to pass "true" in a select variable

…olean

Reorder `schema.oneOf` in `SimplifiedVarsSchema` so `schema.string()` is matched before `schema.boolean()`, preventing string values like "true" and "false" from being coerced to booleans. Adds unit tests to cover this behavior.

Made-with: Cursor
@nchaulet nchaulet self-assigned this Mar 4, 2026
@nchaulet nchaulet requested a review from a team as a code owner March 4, 2026 16:39
@nchaulet nchaulet added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v8.19.13 v9.2.7 v9.3.2 labels Mar 4, 2026
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Mar 4, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/fleet (Team:Fleet)

@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner March 4, 2026 16:56
Copy link
Copy Markdown
Contributor

@MichelLosier MichelLosier left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

@nchaulet nchaulet merged commit cd7eb3d into main Mar 4, 2026
17 checks passed
@nchaulet nchaulet deleted the fix-255976-simplified-policy-variable-boolean-coerce branch March 4, 2026 18:03
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19, 9.2, 9.3

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

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @nchaulet

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 Some backports could not be created

Status Branch Result
8.19 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.19:
- [DOCS][API][SECURITY]: Update "Create Alerts Index" documentation to be more accurate (#255387)
9.2 Backport failed because of merge conflicts
9.3

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 256047

Questions ?

Please refer to the Backport tool documentation

@nchaulet
Copy link
Copy Markdown
Member Author

nchaulet commented Mar 4, 2026

Only backported to 9.3 as the code is too different in 8.19

kibanamachine added a commit that referenced this pull request Mar 4, 2026
… to boolean (#256047) (#256069)

# Backport

This will backport the following commits from `main` to `9.3`:
- [[Fleet] Fix SimplifiedVarsSchema coercing string "true"/"false" to
boolean (#256047)](#256047)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2026-03-04T18:03:13Z","message":"[Fleet]
Fix SimplifiedVarsSchema coercing string \"true\"/\"false\" to boolean
(#256047)","sha":"cd7eb3dbf9ab0e6bbe0dc0aa9a4e8300f7ac38a8","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:version","v9.4.0","v8.19.13","v9.2.7","v9.3.2"],"title":"[Fleet]
Fix SimplifiedVarsSchema coercing string \"true\"/\"false\" to
boolean","number":256047,"url":"https://github.com/elastic/kibana/pull/256047","mergeCommit":{"message":"[Fleet]
Fix SimplifiedVarsSchema coercing string \"true\"/\"false\" to boolean
(#256047)","sha":"cd7eb3dbf9ab0e6bbe0dc0aa9a4e8300f7ac38a8"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.2","9.3"],"targetPullRequestStates":[{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/256047","number":256047,"mergeCommit":{"message":"[Fleet]
Fix SimplifiedVarsSchema coercing string \"true\"/\"false\" to boolean
(#256047)","sha":"cd7eb3dbf9ab0e6bbe0dc0aa9a4e8300f7ac38a8"}},{"branch":"8.19","label":"v8.19.13","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.3","label":"v9.3.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Mar 5, 2026
rbrtj pushed a commit to rbrtj/kibana that referenced this pull request Mar 5, 2026
DennisKo pushed a commit to DennisKo/kibana that referenced this pull request Mar 6, 2026
qn895 pushed a commit to qn895/kibana that referenced this pull request Mar 11, 2026
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:Fleet Team label for Observability Data Collection Fleet team v9.3.2 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fleet] "true"/"false" values cannot be used as options for variables of "select" type with the simplified API

5 participants