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

[UII] Drop ssl field from output if it's in an invalid format #211848

Merged
merged 5 commits into from
Feb 21, 2025

Conversation

jen-huang
Copy link
Contributor

@jen-huang jen-huang commented Feb 19, 2025

Summary

Reported in https://github.com/elastic/sdh-beats/issues/5676. When retrieving outputs information, drop the ssl field if it's in an invalid format (causing JSON.parse to fail).

This can happen for ES output with ssl field set via API, and then subsequently editing it from the UI (ES output ssl fields are currently unsupported, soon to be supported by #207326.

@jen-huang jen-huang added release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team backport:prev-major Backport to (8.x, 8.18, 8.17, 8.16) the previous major branch and other branches in development labels Feb 19, 2025
@jen-huang jen-huang self-assigned this Feb 19, 2025
@jen-huang jen-huang requested a review from a team as a code owner February 19, 2025 20:39
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@@ -128,7 +128,7 @@ function outputSavedObjectToOutput(so: SavedObject<OutputSOAttributes>): Output
return {
id: outputId ?? so.id,
...atributes,
...(ssl ? { ssl: JSON.parse(ssl as string) } : {}),
...(typeof ssl === 'string' ? { ssl: JSON.parse(ssl as string) } : {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

ssl can still be an invalid JSON, even though it's a string. Shouldn't we wrap JSON.parse in try catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, updated code and added unit tests

@jen-huang jen-huang enabled auto-merge (squash) February 20, 2025 19:16
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

cc @jen-huang

Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM

@jen-huang jen-huang merged commit 0c932fd into elastic:main Feb 21, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.16, 8.17, 8.18, 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 21, 2025
…c#211848)

## Summary

Reported in elastic/sdh-beats#5676. When
retrieving outputs information, drop the `ssl` field if it's in an
invalid format (causing `JSON.parse` to fail).

This can happen for ES output with `ssl` field set via API, and then
subsequently editing it from the UI (ES output `ssl` fields are
currently unsupported, soon to be supported by
elastic#207326.

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 0c932fd)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 21, 2025
…c#211848)

## Summary

Reported in elastic/sdh-beats#5676. When
retrieving outputs information, drop the `ssl` field if it's in an
invalid format (causing `JSON.parse` to fail).

This can happen for ES output with `ssl` field set via API, and then
subsequently editing it from the UI (ES output `ssl` fields are
currently unsupported, soon to be supported by
elastic#207326.

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 0c932fd)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

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

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 211848

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 21, 2025
…211848) (#212016)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[UII] Drop ssl field from output if it's in an invalid format
(#211848)](#211848)

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

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

<!--BACKPORT [{"author":{"name":"Jen
Huang","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-21T08:52:17Z","message":"[UII]
Drop ssl field from output if it's in an invalid format (#211848)\n\n##
Summary\n\nReported in elastic/sdh-beats#5676.
When\nretrieving outputs information, drop the `ssl` field if it's in
an\ninvalid format (causing `JSON.parse` to fail).\n\nThis can happen
for ES output with `ssl` field set via API, and then\nsubsequently
editing it from the UI (ES output `ssl` fields are\ncurrently
unsupported, soon to be supported
by\nhttps://github.com//issues/207326.\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"0c932fd4aba794767bf2298911e0f2e2ec2bffb3","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-major","v9.1.0"],"title":"[UII]
Drop ssl field from output if it's in an invalid
format","number":211848,"url":"https://github.com/elastic/kibana/pull/211848","mergeCommit":{"message":"[UII]
Drop ssl field from output if it's in an invalid format (#211848)\n\n##
Summary\n\nReported in elastic/sdh-beats#5676.
When\nretrieving outputs information, drop the `ssl` field if it's in
an\ninvalid format (causing `JSON.parse` to fail).\n\nThis can happen
for ES output with `ssl` field set via API, and then\nsubsequently
editing it from the UI (ES output `ssl` fields are\ncurrently
unsupported, soon to be supported
by\nhttps://github.com//issues/207326.\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"0c932fd4aba794767bf2298911e0f2e2ec2bffb3"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/211848","number":211848,"mergeCommit":{"message":"[UII]
Drop ssl field from output if it's in an invalid format (#211848)\n\n##
Summary\n\nReported in elastic/sdh-beats#5676.
When\nretrieving outputs information, drop the `ssl` field if it's in
an\ninvalid format (causing `JSON.parse` to fail).\n\nThis can happen
for ES output with `ssl` field set via API, and then\nsubsequently
editing it from the UI (ES output `ssl` fields are\ncurrently
unsupported, soon to be supported
by\nhttps://github.com//issues/207326.\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"0c932fd4aba794767bf2298911e0f2e2ec2bffb3"}}]}]
BACKPORT-->

Co-authored-by: Jen Huang <[email protected]>
kibanamachine added a commit that referenced this pull request Feb 21, 2025
…211848) (#212015)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[UII] Drop ssl field from output if it's in an invalid format
(#211848)](#211848)

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

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

<!--BACKPORT [{"author":{"name":"Jen
Huang","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-21T08:52:17Z","message":"[UII]
Drop ssl field from output if it's in an invalid format (#211848)\n\n##
Summary\n\nReported in elastic/sdh-beats#5676.
When\nretrieving outputs information, drop the `ssl` field if it's in
an\ninvalid format (causing `JSON.parse` to fail).\n\nThis can happen
for ES output with `ssl` field set via API, and then\nsubsequently
editing it from the UI (ES output `ssl` fields are\ncurrently
unsupported, soon to be supported
by\nhttps://github.com//issues/207326.\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"0c932fd4aba794767bf2298911e0f2e2ec2bffb3","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-major","v9.1.0"],"title":"[UII]
Drop ssl field from output if it's in an invalid
format","number":211848,"url":"https://github.com/elastic/kibana/pull/211848","mergeCommit":{"message":"[UII]
Drop ssl field from output if it's in an invalid format (#211848)\n\n##
Summary\n\nReported in elastic/sdh-beats#5676.
When\nretrieving outputs information, drop the `ssl` field if it's in
an\ninvalid format (causing `JSON.parse` to fail).\n\nThis can happen
for ES output with `ssl` field set via API, and then\nsubsequently
editing it from the UI (ES output `ssl` fields are\ncurrently
unsupported, soon to be supported
by\nhttps://github.com//issues/207326.\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"0c932fd4aba794767bf2298911e0f2e2ec2bffb3"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/211848","number":211848,"mergeCommit":{"message":"[UII]
Drop ssl field from output if it's in an invalid format (#211848)\n\n##
Summary\n\nReported in elastic/sdh-beats#5676.
When\nretrieving outputs information, drop the `ssl` field if it's in
an\ninvalid format (causing `JSON.parse` to fail).\n\nThis can happen
for ES output with `ssl` field set via API, and then\nsubsequently
editing it from the UI (ES output `ssl` fields are\ncurrently
unsupported, soon to be supported
by\nhttps://github.com//issues/207326.\n\n---------\n\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"0c932fd4aba794767bf2298911e0f2e2ec2bffb3"}}]}]
BACKPORT-->

Co-authored-by: Jen Huang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-major Backport to (8.x, 8.18, 8.17, 8.16) the previous major branch and other branches in development release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.18.0 v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants