Skip to content

[Console] Fix output when HTTP request to server fails#219073

Merged
ElenaStoeva merged 2 commits intoelastic:mainfrom
ElenaStoeva:console/fix-error-response
Apr 25, 2025
Merged

[Console] Fix output when HTTP request to server fails#219073
ElenaStoeva merged 2 commits intoelastic:mainfrom
ElenaStoeva:console/fix-error-response

Conversation

@ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Apr 24, 2025

Follow-up to #218104 (comment)

Summary

This PR fixes the Console output when the HTTP request to the server fails with a non-empty error body. In #218104, we incorrectly set the output to be Request failed to get to the server (status code: ' + statusCode + ') even if there is an error body. In this PR, we make sure to display the error body if it's non-empty.

How to test:

Send a request that fails and verify that the error body is displayed:

POST kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98
{
  "name": "Alert on status change",
  "rule_type_id": ".es-querya"
}
Screenshot 2025-04-24 at 14 41 57

@ElenaStoeva ElenaStoeva added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor v9.1.0 v8.19.0 v8.18.1 v9.0.1 labels Apr 24, 2025
@ElenaStoeva ElenaStoeva self-assigned this Apr 24, 2025
@ElenaStoeva ElenaStoeva requested a review from a team as a code owner April 24, 2025 11:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #13 / Actions and Triggers app Maintenance Windows Maintenance windows table paginates maintenance windows correctly

Metrics [docs]

Async chunks

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

id before after diff
console 186.3KB 186.4KB +37.0B

History

cc @ElenaStoeva

Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

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

Changes lgtm, tested locally.

Nit: The status code and error is already shown in the status bar, perhaps just showing the error message is enough? 🤔

Screenshot 2025-04-25 at 09 21 27

@ElenaStoeva
Copy link
Contributor Author

ElenaStoeva commented Apr 25, 2025

Nit: The status code and error is already shown in the status bar, perhaps just showing the error message is enough?

Do you mean that the status code badge is redundant? I think we still need it because in some situations we don't have the status code displayed in the error response body - for example, from Kibana requests.

Edit: Merging the PR to fix the bug. @sabarasaba let me know if I misunderstood your suggestion - we could address this in a follow-up PR as an enhancement.

@ElenaStoeva ElenaStoeva merged commit cb0acc1 into elastic:main Apr 25, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.19, 9.0

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 25, 2025
Follow-up to
elastic#218104 (comment)

## Summary

This PR fixes the Console output when the HTTP request to the server
fails with a non-empty error body. In
elastic#218104, we incorrectly set the
output to be `Request failed to get to the server (status code: ' +
statusCode + ')` even if there is an error body. In this PR, we make
sure to display the error body if it's non-empty.

**How to test:**

Send a request that fails and verify that the error body is displayed:

```
POST kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98
{
  "name": "Alert on status change",
  "rule_type_id": ".es-querya"
}
```
<img width="1160" alt="Screenshot 2025-04-24 at 14 41 57"
src="https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678"
/>

(cherry picked from commit cb0acc1)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.18 Backport failed because of merge conflicts
8.19
9.0 Backport failed because of merge conflicts

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 219073

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 25, 2025
… (#219295)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Console] Fix output when HTTP request to server fails
(#219073)](#219073)

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

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

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"59341489+ElenaStoeva@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-25T17:09:09Z","message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana
Management","release_note:skip","backport:prev-minor","v9.1.0","v8.19.0","v8.18.1","v9.0.1"],"title":"[Console]
Fix output when HTTP request to server
fails","number":219073,"url":"https://github.com/elastic/kibana/pull/219073","mergeCommit":{"message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","8.18","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219073","number":219073,"mergeCommit":{"message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
ElenaStoeva added a commit to ElenaStoeva/kibana that referenced this pull request Apr 28, 2025
Follow-up to
elastic#218104 (comment)

## Summary

This PR fixes the Console output when the HTTP request to the server
fails with a non-empty error body. In
elastic#218104, we incorrectly set the
output to be `Request failed to get to the server (status code: ' +
statusCode + ')` even if there is an error body. In this PR, we make
sure to display the error body if it's non-empty.

**How to test:**

Send a request that fails and verify that the error body is displayed:

```
POST kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98
{
  "name": "Alert on status change",
  "rule_type_id": ".es-querya"
}
```
<img width="1160" alt="Screenshot 2025-04-24 at 14 41 57"
src="https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678"
/>

(cherry picked from commit cb0acc1)

# Conflicts:
#	src/platform/plugins/shared/console/public/application/hooks/use_send_current_request/send_request.ts
@ElenaStoeva
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.0
8.18

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

Questions ?

Please refer to the Backport tool documentation

ElenaStoeva added a commit to ElenaStoeva/kibana that referenced this pull request Apr 28, 2025
Follow-up to
elastic#218104 (comment)

## Summary

This PR fixes the Console output when the HTTP request to the server
fails with a non-empty error body. In
elastic#218104, we incorrectly set the
output to be `Request failed to get to the server (status code: ' +
statusCode + ')` even if there is an error body. In this PR, we make
sure to display the error body if it's non-empty.

**How to test:**

Send a request that fails and verify that the error body is displayed:

```
POST kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98
{
  "name": "Alert on status change",
  "rule_type_id": ".es-querya"
}
```
<img width="1160" alt="Screenshot 2025-04-24 at 14 41 57"
src="https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678"
/>

(cherry picked from commit cb0acc1)

# Conflicts:
#	src/platform/plugins/shared/console/public/application/hooks/use_send_current_request/send_request.ts
ElenaStoeva added a commit to ElenaStoeva/kibana that referenced this pull request Apr 28, 2025
Follow-up to
elastic#218104 (comment)

This PR fixes the Console output when the HTTP request to the server
fails with a non-empty error body. In
elastic#218104, we incorrectly set the
output to be `Request failed to get to the server (status code: ' +
statusCode + ')` even if there is an error body. In this PR, we make
sure to display the error body if it's non-empty.

**How to test:**

Send a request that fails and verify that the error body is displayed:

```
POST kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98
{
  "name": "Alert on status change",
  "rule_type_id": ".es-querya"
}
```
<img width="1160" alt="Screenshot 2025-04-24 at 14 41 57"
src="https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678"
/>

(cherry picked from commit cb0acc1)
ElenaStoeva added a commit that referenced this pull request Apr 30, 2025
#219439)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Console] Fix output when HTTP request to server fails
(#219073)](#219073)

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

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

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"59341489+ElenaStoeva@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-25T17:09:09Z","message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana
Management","release_note:skip","backport:prev-minor","v9.1.0","v8.19.0","v8.18.1","v9.0.1"],"title":"[Console]
Fix output when HTTP request to server
fails","number":219073,"url":"https://github.com/elastic/kibana/pull/219073","mergeCommit":{"message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad"}},"sourceBranch":"main","suggestedTargetBranches":["8.18","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219073","number":219073,"mergeCommit":{"message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/219295","number":219295,"state":"MERGED","mergeCommit":{"sha":"cd3c92728e0e6792a2dcf8a39b3d8bf71589c929","message":"[8.19]
[Console] Fix output when HTTP request to server fails (#219073)
(#219295)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.19`:\n- [[Console] Fix output when HTTP request to server
fails\n(#219073)](https://github.com/elastic/kibana/pull/219073)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Elena Stoeva
<59341489+ElenaStoeva@users.noreply.github.com>"}},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
ElenaStoeva added a commit that referenced this pull request Apr 30, 2025
… (#219440)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Console] Fix output when HTTP request to server fails
(#219073)](#219073)

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

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

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"59341489+ElenaStoeva@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-25T17:09:09Z","message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana
Management","release_note:skip","backport:prev-minor","v9.1.0","v8.19.0","v8.18.1","v9.0.1"],"title":"[Console]
Fix output when HTTP request to server
fails","number":219073,"url":"https://github.com/elastic/kibana/pull/219073","mergeCommit":{"message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad"}},"sourceBranch":"main","suggestedTargetBranches":["8.18","9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219073","number":219073,"mergeCommit":{"message":"[Console]
Fix output when HTTP request to server fails (#219073)\n\nFollow-up
to\nhttps://github.com//pull/218104#issuecomment-2824757130\n\n##
Summary\n\nThis PR fixes the Console output when the HTTP request to the
server\nfails with a non-empty error body.
In\nhttps://github.com//pull/218104, we incorrectly set
the\noutput to be `Request failed to get to the server (status code: '
+\nstatusCode + ')` even if there is an error body. In this PR, we
make\nsure to display the error body if it's non-empty.\n\n**How to
test:**\n\nSend a request that fails and verify that the error body is
displayed:\n\n```\nPOST
kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98\n{\n
\"name\": \"Alert on status change\",\n \"rule_type_id\":
\".es-querya\"\n}\n```\n<img width=\"1160\" alt=\"Screenshot 2025-04-24
at 14 41
57\"\nsrc=\"https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678\"\n/>","sha":"cb0acc16ee85e4dccc67dcb69dbbba3f328accad"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/219295","number":219295,"state":"MERGED","mergeCommit":{"sha":"cd3c92728e0e6792a2dcf8a39b3d8bf71589c929","message":"[8.19]
[Console] Fix output when HTTP request to server fails (#219073)
(#219295)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.19`:\n- [[Console] Fix output when HTTP request to server
fails\n(#219073)](https://github.com/elastic/kibana/pull/219073)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Elena Stoeva
<59341489+ElenaStoeva@users.noreply.github.com>"}},{"branch":"8.18","label":"v8.18.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
Follow-up to
elastic#218104 (comment)

## Summary

This PR fixes the Console output when the HTTP request to the server
fails with a non-empty error body. In
elastic#218104, we incorrectly set the
output to be `Request failed to get to the server (status code: ' +
statusCode + ')` even if there is an error body. In this PR, we make
sure to display the error body if it's non-empty.

**How to test:**

Send a request that fails and verify that the error body is displayed:

```
POST kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98
{
  "name": "Alert on status change",
  "rule_type_id": ".es-querya"
}
```
<img width="1160" alt="Screenshot 2025-04-24 at 14 41 57"
src="https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678"
/>
@ElenaStoeva ElenaStoeva deleted the console/fix-error-response branch January 31, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Console Dev Tools Console Feature release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// v8.18.1 v8.19.0 v9.0.1 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants