Skip to content

Comments

[Console] Fix output for empty response body#218104

Merged
ElenaStoeva merged 3 commits intoelastic:mainfrom
ElenaStoeva:console/fix-empty-body-response
Apr 14, 2025
Merged

[Console] Fix output for empty response body#218104
ElenaStoeva merged 3 commits intoelastic:mainfrom
ElenaStoeva:console/fix-empty-body-response

Conversation

@ElenaStoeva
Copy link
Contributor

@ElenaStoeva ElenaStoeva commented Apr 14, 2025

Fixes #217433

Summary

This PR fixes the Console output when the response body is an empty string.

In #199975, we made Console to display an OK output if the status code is 200 but response body is null. Previously, POST /_cluster/voting_config_exclusions?node_names=node returned null and so the output was correctly set to OK but now the response is an empty string and this case isn't covered correctly. In this PR, we make sure to perform the right check at the right point so that both null and empty strings are covered.

The test that covers this scenario and had failures:

it('Shows OK when status code is 200 but body is empty', async () => {

To run the failing test with the new Es snapshots:

ES_SNAPSHOT_MANIFEST="https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json" node scripts/functional_tests_server.js --config ./src/platform/test/functional/apps/console/config.ts

and

ES_SNAPSHOT_MANIFEST="https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json" node scripts/functional_test_runner.js  --config ./src/platform/test/functional/apps/console/config.ts --grep="Shows OK when status code is 200 but body is empty"

@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 labels Apr 14, 2025
@ElenaStoeva ElenaStoeva self-assigned this Apr 14, 2025
@ElenaStoeva ElenaStoeva requested a review from a team as a code owner April 14, 2025 12:44
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

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.4KB 186.3KB -28.0B

History

cc @ElenaStoeva

@ElenaStoeva ElenaStoeva enabled auto-merge (squash) April 14, 2025 18:01
Copy link
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

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

Changes are good and work well, thanks!

@ElenaStoeva ElenaStoeva merged commit 170651a into elastic:main Apr 14, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x, 9.0

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 14, 2025
Fixes elastic#217433

## Summary

This PR fixes the Console output when the response body is an empty
string.

In elastic#199975, we made Console to
display an `OK` output if the status code is 200 but response body is
`null`. Previously, `POST
/_cluster/voting_config_exclusions?node_names=node` returned `null` and
so the output was correctly set to `OK` but now the response is an empty
string and this case isn't covered correctly. In this PR, we make sure
to perform the right check at the right point so that both `null` and
empty strings are covered.

The test that covers this scenario and had failures:
https://github.com/elastic/kibana/blob/7092e79157cb8abb229131a1607369324d10969f/src/platform/test/functional/apps/console/_console.ts#L258

To run the failing test with the new Es snapshots:

```
ES_SNAPSHOT_MANIFEST="https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json" node scripts/functional_tests_server.js --config ./src/platform/test/functional/apps/console/config.ts
```

and

```
ES_SNAPSHOT_MANIFEST="https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json" node scripts/functional_test_runner.js  --config ./src/platform/test/functional/apps/console/config.ts --grep="Shows OK when status code is 200 but body is empty"
```

(cherry picked from commit 170651a)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 14, 2025
Fixes elastic#217433

## Summary

This PR fixes the Console output when the response body is an empty
string.

In elastic#199975, we made Console to
display an `OK` output if the status code is 200 but response body is
`null`. Previously, `POST
/_cluster/voting_config_exclusions?node_names=node` returned `null` and
so the output was correctly set to `OK` but now the response is an empty
string and this case isn't covered correctly. In this PR, we make sure
to perform the right check at the right point so that both `null` and
empty strings are covered.

The test that covers this scenario and had failures:
https://github.com/elastic/kibana/blob/7092e79157cb8abb229131a1607369324d10969f/src/platform/test/functional/apps/console/_console.ts#L258

To run the failing test with the new Es snapshots:

```
ES_SNAPSHOT_MANIFEST="https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json" node scripts/functional_tests_server.js --config ./src/platform/test/functional/apps/console/config.ts
```

and

```
ES_SNAPSHOT_MANIFEST="https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json" node scripts/functional_test_runner.js  --config ./src/platform/test/functional/apps/console/config.ts --grep="Shows OK when status code is 200 but body is empty"
```

(cherry picked from commit 170651a)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x
9.0

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 Apr 14, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Console] Fix output for empty response body
(#218104)](#218104)

<!--- 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-14T22:06:14Z","message":"[Console]
Fix output for empty response body (#218104)\n\nFixes
https://github.com/elastic/kibana/issues/217433\n\n## Summary\n\nThis PR
fixes the Console output when the response body is an
empty\nstring.\n\nIn #199975, we
made Console to\ndisplay an `OK` output if the status code is 200 but
response body is\n`null`. Previously,
`POST\n/_cluster/voting_config_exclusions?node_names=node` returned
`null` and\nso the output was correctly set to `OK` but now the response
is an empty\nstring and this case isn't covered correctly. In this PR,
we make sure\nto perform the right check at the right point so that both
`null` and\nempty strings are covered.\n\nThe test that covers this
scenario and had
failures:\nhttps://github.com/elastic/kibana/blob/7092e79157cb8abb229131a1607369324d10969f/src/platform/test/functional/apps/console/_console.ts#L258\n\n\nTo
run the failing test with the new Es
snapshots:\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json\"
node scripts/functional_tests_server.js --config
./src/platform/test/functional/apps/console/config.ts\n```\n\nand
\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json\"
node scripts/functional_test_runner.js --config
./src/platform/test/functional/apps/console/config.ts --grep=\"Shows OK
when status code is 200 but body is
empty\"\n```","sha":"170651ac78595f6fe8e2ab4924fd5300b8a4f14e","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^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"],"title":"[Console]
Fix output for empty response
body","number":218104,"url":"https://github.com/elastic/kibana/pull/218104","mergeCommit":{"message":"[Console]
Fix output for empty response body (#218104)\n\nFixes
https://github.com/elastic/kibana/issues/217433\n\n## Summary\n\nThis PR
fixes the Console output when the response body is an
empty\nstring.\n\nIn #199975, we
made Console to\ndisplay an `OK` output if the status code is 200 but
response body is\n`null`. Previously,
`POST\n/_cluster/voting_config_exclusions?node_names=node` returned
`null` and\nso the output was correctly set to `OK` but now the response
is an empty\nstring and this case isn't covered correctly. In this PR,
we make sure\nto perform the right check at the right point so that both
`null` and\nempty strings are covered.\n\nThe test that covers this
scenario and had
failures:\nhttps://github.com/elastic/kibana/blob/7092e79157cb8abb229131a1607369324d10969f/src/platform/test/functional/apps/console/_console.ts#L258\n\n\nTo
run the failing test with the new Es
snapshots:\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json\"
node scripts/functional_tests_server.js --config
./src/platform/test/functional/apps/console/config.ts\n```\n\nand
\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json\"
node scripts/functional_test_runner.js --config
./src/platform/test/functional/apps/console/config.ts --grep=\"Shows OK
when status code is 200 but body is
empty\"\n```","sha":"170651ac78595f6fe8e2ab4924fd5300b8a4f14e"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218104","number":218104,"mergeCommit":{"message":"[Console]
Fix output for empty response body (#218104)\n\nFixes
https://github.com/elastic/kibana/issues/217433\n\n## Summary\n\nThis PR
fixes the Console output when the response body is an
empty\nstring.\n\nIn #199975, we
made Console to\ndisplay an `OK` output if the status code is 200 but
response body is\n`null`. Previously,
`POST\n/_cluster/voting_config_exclusions?node_names=node` returned
`null` and\nso the output was correctly set to `OK` but now the response
is an empty\nstring and this case isn't covered correctly. In this PR,
we make sure\nto perform the right check at the right point so that both
`null` and\nempty strings are covered.\n\nThe test that covers this
scenario and had
failures:\nhttps://github.com/elastic/kibana/blob/7092e79157cb8abb229131a1607369324d10969f/src/platform/test/functional/apps/console/_console.ts#L258\n\n\nTo
run the failing test with the new Es
snapshots:\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json\"
node scripts/functional_tests_server.js --config
./src/platform/test/functional/apps/console/config.ts\n```\n\nand
\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json\"
node scripts/functional_test_runner.js --config
./src/platform/test/functional/apps/console/config.ts --grep=\"Shows OK
when status code is 200 but body is
empty\"\n```","sha":"170651ac78595f6fe8e2ab4924fd5300b8a4f14e"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Apr 16, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

kibanamachine added a commit that referenced this pull request Apr 17, 2025
# Backport

This will backport the following commits from `main` to `9.0`:
- [[Console] Fix output for empty response body
(#218104)](#218104)

<!--- 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-14T22:06:14Z","message":"[Console]
Fix output for empty response body (#218104)\n\nFixes
https://github.com/elastic/kibana/issues/217433\n\n## Summary\n\nThis PR
fixes the Console output when the response body is an
empty\nstring.\n\nIn #199975, we
made Console to\ndisplay an `OK` output if the status code is 200 but
response body is\n`null`. Previously,
`POST\n/_cluster/voting_config_exclusions?node_names=node` returned
`null` and\nso the output was correctly set to `OK` but now the response
is an empty\nstring and this case isn't covered correctly. In this PR,
we make sure\nto perform the right check at the right point so that both
`null` and\nempty strings are covered.\n\nThe test that covers this
scenario and had
failures:\nhttps://github.com/elastic/kibana/blob/7092e79157cb8abb229131a1607369324d10969f/src/platform/test/functional/apps/console/_console.ts#L258\n\n\nTo
run the failing test with the new Es
snapshots:\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json\"
node scripts/functional_tests_server.js --config
./src/platform/test/functional/apps/console/config.ts\n```\n\nand
\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json\"
node scripts/functional_test_runner.js --config
./src/platform/test/functional/apps/console/config.ts --grep=\"Shows OK
when status code is 200 but body is
empty\"\n```","sha":"170651ac78595f6fe8e2ab4924fd5300b8a4f14e","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^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"],"title":"[Console]
Fix output for empty response
body","number":218104,"url":"https://github.com/elastic/kibana/pull/218104","mergeCommit":{"message":"[Console]
Fix output for empty response body (#218104)\n\nFixes
https://github.com/elastic/kibana/issues/217433\n\n## Summary\n\nThis PR
fixes the Console output when the response body is an
empty\nstring.\n\nIn #199975, we
made Console to\ndisplay an `OK` output if the status code is 200 but
response body is\n`null`. Previously,
`POST\n/_cluster/voting_config_exclusions?node_names=node` returned
`null` and\nso the output was correctly set to `OK` but now the response
is an empty\nstring and this case isn't covered correctly. In this PR,
we make sure\nto perform the right check at the right point so that both
`null` and\nempty strings are covered.\n\nThe test that covers this
scenario and had
failures:\nhttps://github.com/elastic/kibana/blob/7092e79157cb8abb229131a1607369324d10969f/src/platform/test/functional/apps/console/_console.ts#L258\n\n\nTo
run the failing test with the new Es
snapshots:\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json\"
node scripts/functional_tests_server.js --config
./src/platform/test/functional/apps/console/config.ts\n```\n\nand
\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json\"
node scripts/functional_test_runner.js --config
./src/platform/test/functional/apps/console/config.ts --grep=\"Shows OK
when status code is 200 but body is
empty\"\n```","sha":"170651ac78595f6fe8e2ab4924fd5300b8a4f14e"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218104","number":218104,"mergeCommit":{"message":"[Console]
Fix output for empty response body (#218104)\n\nFixes
https://github.com/elastic/kibana/issues/217433\n\n## Summary\n\nThis PR
fixes the Console output when the response body is an
empty\nstring.\n\nIn #199975, we
made Console to\ndisplay an `OK` output if the status code is 200 but
response body is\n`null`. Previously,
`POST\n/_cluster/voting_config_exclusions?node_names=node` returned
`null` and\nso the output was correctly set to `OK` but now the response
is an empty\nstring and this case isn't covered correctly. In this PR,
we make sure\nto perform the right check at the right point so that both
`null` and\nempty strings are covered.\n\nThe test that covers this
scenario and had
failures:\nhttps://github.com/elastic/kibana/blob/7092e79157cb8abb229131a1607369324d10969f/src/platform/test/functional/apps/console/_console.ts#L258\n\n\nTo
run the failing test with the new Es
snapshots:\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/8.19.0/archives/20250414-022022_f16f4ce6/manifest.json\"
node scripts/functional_tests_server.js --config
./src/platform/test/functional/apps/console/config.ts\n```\n\nand
\n\n```\nES_SNAPSHOT_MANIFEST=\"https://storage.googleapis.com/kibana-ci-es-snapshots-daily/9.1.0/archives/20250414-021844_4ed1a000/manifest.json\"
node scripts/functional_test_runner.js --config
./src/platform/test/functional/apps/console/config.ts --grep=\"Shows OK
when status code is 200 but body is
empty\"\n```","sha":"170651ac78595f6fe8e2ab4924fd5300b8a4f14e"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

---------

Co-authored-by: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
Co-authored-by: Elena Stoeva <elenastoeva99@gmail.com>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Apr 17, 2025
@nchaulet
Copy link
Member

nchaulet commented Apr 23, 2025

Hi @mattkime @ElenaStoeva looks like since that change we are not showing body for any errors even when there is a body it is expected? it seems to me there is still some value for users to get that body no?

Screenshot 2025-04-23 at 11 47 05 AM

@ElenaStoeva
Copy link
Contributor Author

Hi @nchaulet, can you provide the request that caused this response?

@nchaulet
Copy link
Member

Sure here it is, any non 200 seems to trigger that response even if there is a body

POST kbn:/api/alerting/rule/3603c386-9102-4c74-800d-2242e52bec98
{
  "name": "Alert on status change",
  "rule_type_id": ".es-querya",
    "consumer": "stackAlerts",
  "tags": [],
  "schedule": {
    "interval": "1m"
  },
  "params": {
    "searchType": "esqlQuery",
    "timeWindowSize": 5,
    "timeWindowUnit": "m",
    "threshold": [
      0
    ],
    "thresholdComparator": ">",
    "size": 100,
    "esqlQuery": {
      "esql": "FROM logs-elastic_agent.status_change-default \n | WHERE status ==   \"ONLINE\"\n  | STATS count = COUNT(*) BY agent.id  /* you can group by a field using the BY operator */"
    },
    "aggType": "count",
    "groupBy": "row",
    "termSize": 10000,
    "termField": "agent.id",
    "sourceFields": [],
    "timeField": "@timestamp",
    "excludeHitsFromPreviousRun": true
  },
  "actions": [],
  "alert_delay": {
    "active": 1
  }
}

@ElenaStoeva
Copy link
Contributor Author

Thanks for reporting this @nchaulet! I created #219073 to fix this regression.

ElenaStoeva added a commit that referenced this pull request Apr 25, 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"
}
```
<img width="1160" alt="Screenshot 2025-04-24 at 14 41 57"
src="https://github.com/user-attachments/assets/ced78171-4924-477f-ba2f-d5812bff1678"
/>
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 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 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-empty-body-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.19.0 v9.0.1 v9.1.0

Projects

None yet

5 participants