Skip to content

[Rules] Fixed infinite loop bug in investigation guide editor#240472

Merged
cesco-f merged 15 commits intoelastic:mainfrom
cesco-f:fix-markdown-editor
Oct 29, 2025
Merged

[Rules] Fixed infinite loop bug in investigation guide editor#240472
cesco-f merged 15 commits intoelastic:mainfrom
cesco-f:fix-markdown-editor

Conversation

@cesco-f
Copy link
Contributor

@cesco-f cesco-f commented Oct 24, 2025

When length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH this code was constantly setting a new errorMessages causing a Maximum update depth exceeded error.

In this PR we also set a new value for MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH.

  const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
  const onParse = useCallback(
    (_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
      const length = ast.position?.end.offset ?? 0;
      if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
        setErrorMessages([
          i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
            defaultMessage:
              'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
            values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
          }),
        ]);
      } else if (errorMessages.length) {
        setErrorMessages([]);
      }
    },
    [errorMessages]
  );

Before:

Screen.Recording.2025-10-24.at.17.25.19.mov

After:

Screen.Recording.2025-10-24.at.17.25.46.mov
@cesco-f cesco-f added release_note:fix backport:version Backport to applied version labels v9.2.1 labels Oct 24, 2025
@github-actions github-actions bot added the author:obs-ux-management PRs authored by the obs ux management team label Oct 24, 2025
@cesco-f cesco-f marked this pull request as ready for review October 27, 2025 07:31
@cesco-f cesco-f requested a review from a team as a code owner October 27, 2025 07:31
@cesco-f
Copy link
Contributor Author

cesco-f commented Oct 27, 2025

/ci

@cesco-f cesco-f requested a review from a team as a code owner October 27, 2025 10:51
…t --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/streams --include-path /api/fleet --include-path /api/saved_objects/_import --include-path /api/saved_objects/_export --include-path /api/maintenance_window --include-path /api/agent_builder --update'
@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod bot requested a review from a team as a code owner October 27, 2025 13:34
@cesco-f cesco-f force-pushed the fix-markdown-editor branch from 8299324 to 1a88a3d Compare October 27, 2025 14:10
@cesco-f cesco-f force-pushed the fix-markdown-editor branch 2 times, most recently from 33429a6 to 7f520b4 Compare October 27, 2025 14:13
}
},
[errorMessages]
[errorMessages.length]
Copy link
Contributor Author

@cesco-f cesco-f Oct 27, 2025

Choose a reason for hiding this comment

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

Just a heads up that I slightly changed the logic here because I realized I was not showing the current length in the error message.

Here the commit: d4c6cfe.

cc @cnasikas @jcger

@cesco-f cesco-f force-pushed the fix-markdown-editor branch from 7f520b4 to d4c6cfe Compare October 27, 2025 14:30
@cesco-f cesco-f removed the request for review from a team October 28, 2025 07:03
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 2034 2036 +2
datasetQuality 883 885 +2
discover 1645 1647 +2
infra 1610 1612 +2
ml 2549 2551 +2
monitoring 761 763 +2
observability 1560 1562 +2
slo 1295 1297 +2
synthetics 1381 1383 +2
transform 809 811 +2
triggersActionsUi 1084 1086 +2
uptime 904 906 +2
total +24

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 2.8MB 2.8MB +13.0B
datasetQuality 422.9KB 422.9KB +13.0B
discover 1.2MB 1.2MB +10.0B
infra 1.1MB 1.1MB +13.0B
ml 5.4MB 5.4MB +22.0B
monitoring 633.6KB 633.6KB +13.0B
observability 1.7MB 1.7MB +60.0B
slo 983.3KB 983.3KB +13.0B
synthetics 1.0MB 1.0MB +19.0B
transform 623.8KB 623.8KB +13.0B
triggersActionsUi 1.5MB 1.5MB +59.0B
uptime 492.1KB 492.1KB +13.0B
total +261.0B

History

Copy link
Contributor

@mgiota mgiota left a comment

Choose a reason for hiding this comment

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

LGTM!

@cesco-f cesco-f merged commit 4e74c80 into elastic:main Oct 29, 2025
13 checks passed
@cesco-f cesco-f deleted the fix-markdown-editor branch October 29, 2025 07:57
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1, 9.2

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

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Oct 29, 2025
…c#240472)

When `length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code was
constantly setting a new `errorMessages` causing a `Maximum update depth
exceeded` error.

In this PR we also set a new value for
`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.

```
  const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
  const onParse = useCallback(
    (_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
      const length = ast.position?.end.offset ?? 0;
      if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
        setErrorMessages([
          i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
            defaultMessage:
              'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
            values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
          }),
        ]);
      } else if (errorMessages.length) {
        setErrorMessages([]);
      }
    },
    [errorMessages]
  );
```

Before:

https://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9

After:

https://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 4e74c80)
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Oct 29, 2025
…c#240472)

When `length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code was
constantly setting a new `errorMessages` causing a `Maximum update depth
exceeded` error.

In this PR we also set a new value for
`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.

```
  const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
  const onParse = useCallback(
    (_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
      const length = ast.position?.end.offset ?? 0;
      if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
        setErrorMessages([
          i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
            defaultMessage:
              'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
            values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
          }),
        ]);
      } else if (errorMessages.length) {
        setErrorMessages([]);
      }
    },
    [errorMessages]
  );
```

Before:

https://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9

After:

https://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 4e74c80)
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Oct 29, 2025
…c#240472)

When `length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code was
constantly setting a new `errorMessages` causing a `Maximum update depth
exceeded` error.

In this PR we also set a new value for
`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.

```
  const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
  const onParse = useCallback(
    (_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
      const length = ast.position?.end.offset ?? 0;
      if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
        setErrorMessages([
          i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
            defaultMessage:
              'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
            values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
          }),
        ]);
      } else if (errorMessages.length) {
        setErrorMessages([]);
      }
    },
    [errorMessages]
  );
```

Before:

https://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9

After:

https://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 4e74c80)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19
9.1
9.2

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

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 29, 2025
…240472) (#241069)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Rules] Fixed infinite loop bug in investigation guide editor
(#240472)](#240472)

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

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

<!--BACKPORT [{"author":{"name":"Francesco
Fagnani","email":"fagnani.francesco@gmail.com"},"sourceCommit":{"committedDate":"2025-10-29T07:57:02Z","message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:version","author:obs-ux-management","v9.3.0","v8.19.7","v9.1.7","v9.2.1"],"title":"[Rules]
Fixed infinite loop bug in investigation guide
editor","number":240472,"url":"https://github.com/elastic/kibana/pull/240472","mergeCommit":{"message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.1","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240472","number":240472,"mergeCommit":{"message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158"}},{"branch":"8.19","label":"v8.19.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.1","label":"v9.1.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Francesco Fagnani <fagnani.francesco@gmail.com>
kibanamachine added a commit that referenced this pull request Oct 29, 2025
…240472) (#241070)

# Backport

This will backport the following commits from `main` to `9.2`:
- [[Rules] Fixed infinite loop bug in investigation guide editor
(#240472)](#240472)

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

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

<!--BACKPORT [{"author":{"name":"Francesco
Fagnani","email":"fagnani.francesco@gmail.com"},"sourceCommit":{"committedDate":"2025-10-29T07:57:02Z","message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:version","author:obs-ux-management","v9.3.0","v8.19.7","v9.1.7","v9.2.1"],"title":"[Rules]
Fixed infinite loop bug in investigation guide
editor","number":240472,"url":"https://github.com/elastic/kibana/pull/240472","mergeCommit":{"message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.1","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240472","number":240472,"mergeCommit":{"message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158"}},{"branch":"8.19","label":"v8.19.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.1","label":"v9.1.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Francesco Fagnani <fagnani.francesco@gmail.com>
kibanamachine added a commit that referenced this pull request Oct 29, 2025
…240472) (#241068)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Rules] Fixed infinite loop bug in investigation guide editor
(#240472)](#240472)

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

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

<!--BACKPORT [{"author":{"name":"Francesco
Fagnani","email":"fagnani.francesco@gmail.com"},"sourceCommit":{"committedDate":"2025-10-29T07:57:02Z","message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:version","author:obs-ux-management","v9.3.0","v8.19.7","v9.1.7","v9.2.1"],"title":"[Rules]
Fixed infinite loop bug in investigation guide
editor","number":240472,"url":"https://github.com/elastic/kibana/pull/240472","mergeCommit":{"message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.1","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240472","number":240472,"mergeCommit":{"message":"[Rules]
Fixed infinite loop bug in investigation guide editor (#240472)\n\nWhen
`length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code
was\nconstantly setting a new `errorMessages` causing a `Maximum update
depth\nexceeded` error.\n\nIn this PR we also set a new value
for\n`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.\n\n```\n const
[errorMessages, setErrorMessages] = React.useState<string[]>([]);\n
const onParse = useCallback(\n (_: EuiMarkdownParseError | null, { ast
}: { ast: EuiMarkdownAstNode }) => {\n const length =
ast.position?.end.offset ?? 0;\n if (length >
MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {\n setErrorMessages([\n
i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage',
{\n defaultMessage:\n 'The Investigation Guide is too long. Please
shorten it.\\nCurrent length: {length}.\\nMax length: {maxLength}.',\n
values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH
},\n }),\n ]);\n } else if (errorMessages.length) {\n
setErrorMessages([]);\n }\n },\n [errorMessages]\n
);\n```\n\nBefore:\n\n\nhttps://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9\n\nAfter:\n\n\nhttps://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4\n\n---------\n\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4e74c80733d4aa53800204146f667771371ba158"}},{"branch":"8.19","label":"v8.19.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.1","label":"v9.1.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Francesco Fagnani <fagnani.francesco@gmail.com>
tkajtoch pushed a commit to tkajtoch/kibana that referenced this pull request Oct 29, 2025
…c#240472)

When `length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code was
constantly setting a new `errorMessages` causing a `Maximum update depth
exceeded` error.

In this PR we also set a new value for
`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.

```
  const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
  const onParse = useCallback(
    (_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
      const length = ast.position?.end.offset ?? 0;
      if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
        setErrorMessages([
          i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
            defaultMessage:
              'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
            values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
          }),
        ]);
      } else if (errorMessages.length) {
        setErrorMessages([]);
      }
    },
    [errorMessages]
  );
```

Before:


https://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9

After:


https://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
qn895 pushed a commit to qn895/kibana that referenced this pull request Oct 30, 2025
…c#240472)

When `length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code was
constantly setting a new `errorMessages` causing a `Maximum update depth
exceeded` error.

In this PR we also set a new value for
`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.

```
  const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
  const onParse = useCallback(
    (_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
      const length = ast.position?.end.offset ?? 0;
      if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
        setErrorMessages([
          i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
            defaultMessage:
              'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
            values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
          }),
        ]);
      } else if (errorMessages.length) {
        setErrorMessages([]);
      }
    },
    [errorMessages]
  );
```

Before:


https://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9

After:


https://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
ana-davydova pushed a commit to ana-davydova/kibana that referenced this pull request Nov 3, 2025
…c#240472)

When `length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code was
constantly setting a new `errorMessages` causing a `Maximum update depth
exceeded` error.

In this PR we also set a new value for
`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.

```
  const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
  const onParse = useCallback(
    (_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
      const length = ast.position?.end.offset ?? 0;
      if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
        setErrorMessages([
          i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
            defaultMessage:
              'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
            values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
          }),
        ]);
      } else if (errorMessages.length) {
        setErrorMessages([]);
      }
    },
    [errorMessages]
  );
```

Before:


https://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9

After:


https://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
albertoblaz pushed a commit to albertoblaz/kibana that referenced this pull request Nov 4, 2025
…c#240472)

When `length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH` this code was
constantly setting a new `errorMessages` causing a `Maximum update depth
exceeded` error.

In this PR we also set a new value for
`MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH`.

```
  const [errorMessages, setErrorMessages] = React.useState<string[]>([]);
  const onParse = useCallback(
    (_: EuiMarkdownParseError | null, { ast }: { ast: EuiMarkdownAstNode }) => {
      const length = ast.position?.end.offset ?? 0;
      if (length > MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH) {
        setErrorMessages([
          i18n.translate('responseOpsRuleForm.investigationGuide.editor.errorMessage', {
            defaultMessage:
              'The Investigation Guide is too long. Please shorten it.\nCurrent length: {length}.\nMax length: {maxLength}.',
            values: { length, maxLength: MAX_ARTIFACTS_INVESTIGATION_GUIDE_LENGTH },
          }),
        ]);
      } else if (errorMessages.length) {
        setErrorMessages([]);
      }
    },
    [errorMessages]
  );
```

Before:


https://github.com/user-attachments/assets/5a07984c-f9bf-4938-b31b-c4375558dca9

After:


https://github.com/user-attachments/assets/a7f1f132-6e1f-41df-9320-6a0abe2041a4

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author:obs-ux-management PRs authored by the obs ux management team backport:version Backport to applied version labels release_note:fix v8.19.7 v9.1.7 v9.2.1 v9.3.0

7 participants