Skip to content

[kbnClient] fix basePath handling and export reponse type#97277

Merged
spalger merged 2 commits intoelastic:masterfrom
spalger:fix/kbn-client/basepath-and-export-reponse-type
Apr 16, 2021
Merged

[kbnClient] fix basePath handling and export reponse type#97277
spalger merged 2 commits intoelastic:masterfrom
spalger:fix/kbn-client/basepath-and-export-reponse-type

Conversation

@spalger
Copy link
Contributor

@spalger spalger commented Apr 15, 2021

The KbnClient does not currently handle a basePath in the Kibana URL very well. It works when you specify the basePath as ending with a /, and when the code in the client requests a URL starting without a /, but only then. This code automatically adds the trailing slash to the Kibana URL if it's missing and strips the leading / from paths before resolving URLs for requests.

Additionally, this fixes an issue in KbnClientImportExport#export() where an export of a single object is always parsed as JSON by a default response transformer in Axios (tracked by this issue) by supporting the responseType option, and overwriting the default responseTransformer when it is set to "text".

@spalger spalger added Team:Operations Kibana-Operations Team v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.13.0 labels Apr 15, 2021
@spalger
Copy link
Contributor Author

spalger commented Apr 15, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

API count

id before after diff
actions - 113 +113
advancedSettings - 18 +18
alerting - 200 +200
apm - 35 +35
apmOss - 38 +38
banners - 9 +9
beatsManagement - 2 +2
bfetch - 58 +58
canvas - 4 +4
cases - 2 +2
charts - 157 +157
cloud - 19 +19
console - 2 +2
core - 2168 +2168
dashboard - 138 +138
dashboardEnhanced - 51 +51
dashboardMode - 11 +11
data - 3436 +3436
dataEnhanced - 52 +52
devTools - 9 +9
discover - 61 +61
discoverEnhanced - 39 +39
embeddable - 426 +426
embeddableEnhanced - 14 +14
encryptedSavedObjects - 20 +20
enterpriseSearch - 2 +2
esUiShared - 84 +84
eventLog - 70 +70
expressions - 1755 +1755
features - 199 +199
fileUpload - 175 +175
fleet - 1075 +1075
globalSearch - 67 +67
home - 91 +91
indexLifecycleManagement - 5 +5
indexManagement - 162 +162
indexPatternFieldEditor - 29 +29
indexPatternManagement - 46 +46
infra - 14 +14
ingestPipelines - 9 +9
inspector - 97 +97
kibanaLegacy - 92 +92
kibanaReact - 232 +232
kibanaUtils - 465 +465
lens - 160 +160
licenseManagement - 3 +3
licensing - 116 +116
lists - 251 +251
management - 35 +35
maps - 182 +182
mapsEms - 69 +69
ml - 343 +343
monitoring - 9 +9
navigation - 29 +29
newsfeed - 17 +17
observability - 176 +176
osquery - 8 +8
presentationUtil - 69 +69
remoteClusters - 4 +4
reporting - 127 +127
rollup - 20 +20
ruleRegistry - 52 +52
runtimeFields - 22 +22
savedObjects - 173 +173
savedObjectsManagement - 91 +91
savedObjectsTagging - 54 +54
savedObjectsTaggingOss - 81 +81
security - 79 +79
securityOss - 11 +11
securitySolution - 99 +99
share - 66 +66
snapshotRestore - 22 +22
spaces - 82 +82
spacesOss - 64 +64
stackAlerts - 4 +4
taskManager - 41 +41
telemetry - 41 +41
telemetryCollectionManager - 24 +24
telemetryCollectionXpack - 1 +1
telemetryManagementSection - 13 +13
timelines - 6 +6
triggersActionsUi - 221 +221
uiActions - 127 +127
uiActionsEnhanced - 185 +185
uptime - 5 +5
urlForwarding - 14 +14
usageCollection - 53 +53
visTypeTimeseries - 7 +7
visualizations - 212 +212
total +15219

API count missing comments

id before after diff
actions - 113 +113
advancedSettings - 17 +17
alerting - 200 +200
apm - 35 +35
apmOss - 38 +38
banners - 9 +9
beatsManagement - 2 +2
bfetch - 47 +47
canvas - 3 +3
cases - 2 +2
charts - 132 +132
cloud - 19 +19
console - 2 +2
core - 989 +989
dashboard - 126 +126
dashboardEnhanced - 50 +50
dashboardMode - 11 +11
data - 2944 +2944
dataEnhanced - 34 +34
devTools - 8 +8
discover - 48 +48
discoverEnhanced - 37 +37
embeddable - 361 +361
embeddableEnhanced - 14 +14
encryptedSavedObjects - 18 +18
enterpriseSearch - 2 +2
esUiShared - 82 +82
eventLog - 70 +70
expressions - 1364 +1364
features - 89 +89
fileUpload - 175 +175
fleet - 985 +985
globalSearch - 13 +13
home - 67 +67
indexLifecycleManagement - 5 +5
indexManagement - 157 +157
indexPatternFieldEditor - 27 +27
indexPatternManagement - 46 +46
infra - 11 +11
ingestPipelines - 9 +9
inspector - 77 +77
kibanaLegacy - 84 +84
kibanaReact - 207 +207
kibanaUtils - 301 +301
lens - 149 +149
licenseManagement - 3 +3
licensing - 40 +40
lists - 234 +234
management - 35 +35
maps - 181 +181
mapsEms - 69 +69
ml - 339 +339
monitoring - 9 +9
navigation - 29 +29
newsfeed - 17 +17
observability - 176 +176
osquery - 8 +8
presentationUtil - 67 +67
remoteClusters - 4 +4
reporting - 126 +126
rollup - 20 +20
ruleRegistry - 52 +52
runtimeFields - 17 +17
savedObjects - 159 +159
savedObjectsManagement - 80 +80
savedObjectsTagging - 50 +50
savedObjectsTaggingOss - 42 +42
security - 38 +38
securityOss - 8 +8
securitySolution - 90 +90
share - 60 +60
snapshotRestore - 22 +22
spaces - 65 +65
spacesOss - 29 +29
stackAlerts - 4 +4
taskManager - 16 +16
telemetry - 37 +37
telemetryCollectionManager - 24 +24
telemetryCollectionXpack - 1 +1
telemetryManagementSection - 12 +12
timelines - 6 +6
triggersActionsUi - 212 +212
uiActions - 88 +88
uiActionsEnhanced - 135 +135
uptime - 5 +5
urlForwarding - 14 +14
usageCollection - 46 +46
visTypeTimeseries - 7 +7
visualizations - 194 +194
total +12049

API count with any type

id before after diff
bfetch - 1 +1
charts - 2 +2
core - 147 +147
dashboard - 1 +1
data - 81 +81
embeddable - 2 +2
esUiShared - 4 +4
expressions - 44 +44
fileUpload - 6 +6
fleet - 16 +16
indexManagement - 12 +12
inspector - 6 +6
kibanaLegacy - 3 +3
kibanaUtils - 3 +3
maps - 2 +2
mapsEms - 1 +1
ml - 14 +14
reporting - 1 +1
ruleRegistry - 1 +1
savedObjects - 3 +3
share - 1 +1
snapshotRestore - 1 +1
triggersActionsUi - 1 +1
visualizations - 11 +11
total +364

Non-exported public API item count

id before after diff
actions - 6 +6
advancedSettings - 1 +1
alerting - 9 +9
apm - 8 +8
bfetch - 2 +2
canvas - 2 +2
cases - 1 +1
charts - 2 +2
core - 29 +29
dashboard - 9 +9
data - 76 +76
dataEnhanced - 2 +2
devTools - 2 +2
discover - 6 +6
discoverEnhanced - 2 +2
embeddable - 3 +3
encryptedSavedObjects - 4 +4
esUiShared - 4 +4
eventLog - 4 +4
expressions - 7 +7
features - 1 +1
fleet - 10 +10
globalSearch - 6 +6
home - 8 +8
indexManagement - 4 +4
indexPatternFieldEditor - 4 +4
indexPatternManagement - 4 +4
infra - 2 +2
ingestPipelines - 4 +4
inspector - 4 +4
kibanaLegacy - 1 +1
kibanaReact - 3 +3
kibanaUtils - 8 +8
lens - 12 +12
licensing - 10 +10
lists - 60 +60
management - 4 +4
maps - 16 +16
ml - 34 +34
navigation - 3 +3
observability - 7 +7
presentationUtil - 4 +4
reporting - 18 +18
ruleRegistry - 4 +4
runtimeFields - 2 +2
savedObjects - 5 +5
savedObjectsManagement - 1 +1
security - 10 +10
securityOss - 3 +3
securitySolution - 7 +7
share - 3 +3
snapshotRestore - 1 +1
spaces - 3 +3
taskManager - 3 +3
telemetry - 3 +3
telemetryCollectionManager - 4 +4
timelines - 1 +1
triggersActionsUi - 28 +28
uiActions - 9 +9
uiActionsEnhanced - 10 +10
uptime - 3 +3
usageCollection - 7 +7
visTypeTimeseries - 2 +2
visualizations - 6 +6
total +521

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@spalger spalger marked this pull request as ready for review April 15, 2021 20:40
@spalger spalger requested a review from a team as a code owner April 15, 2021 20:40
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

Copy link
Member

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

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

Change LGTM, not sure what's up with the metrics.

@spalger spalger merged commit 9987e3d into elastic:master Apr 16, 2021
@spalger spalger added the auto-backport Deprecated - use backport:version if exact versions are needed label Apr 16, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 16, 2021
)

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Apr 16, 2021
…97353)

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Spencer <email@spalger.com>
Co-authored-by: spalger <spalger@users.noreply.github.com>
@spalger spalger deleted the fix/kbn-client/basepath-and-export-reponse-type branch April 16, 2021 07:47
jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 19, 2021
…te-legacy-es-client

* 'master' of github.com:elastic/kibana: (102 commits)
  [Exploratory view] integerate page views to exploratory view (elastic#97258)
  Fix typo in license_api_guard README name and import http server mocks from public interface (elastic#97334)
  Avoid mutating KQL query when validating it (elastic#97081)
  Add description as title on tag badge (elastic#97109)
  Remove legacy ES client usages in `home` and `xpack_legacy` (elastic#97359)
  [Fleet] Finer-grained error information from install/upgrade API (elastic#95649)
  Rule registry bundle size (elastic#97251)
  [Partial Results] Move other bucket into Search Source (elastic#96384)
  [Dashboard] Makes lens default editor for creating new panels (elastic#96181)
  skip flaky suite (elastic#97387)
  [Asset Management] Agent picker follow up (elastic#97357)
  skip flaky suite (elastic#97382)
  [Security Solutions] Fixes flake with cypress tests (elastic#97329)
  skip flaky suite (elastic#97355)
  Skip test to try and stabilize master
  minimize number of so fild asserted in tests. it creates flakines when implementation details change (elastic#97374)
  [Search Sessions] Client side search cache (elastic#92439)
  [SavedObjects] Add aggregations support (elastic#96292)
  [Reporting] Remove legacy elasticsearch client usage from the reporting plugin (elastic#97184)
  [kbnClient] fix basePath handling and export reponse type (elastic#97277)
  ...

# Conflicts:
#	x-pack/plugins/watcher/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts
#	x-pack/plugins/watcher/server/plugin.ts
#	x-pack/plugins/watcher/server/routes/api/indices/register_get_route.ts
#	x-pack/plugins/watcher/server/routes/api/license/register_refresh_route.ts
#	x-pack/plugins/watcher/server/routes/api/register_list_fields_route.ts
#	x-pack/plugins/watcher/server/routes/api/register_load_history_route.ts
#	x-pack/plugins/watcher/server/routes/api/settings/register_load_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/action/register_acknowledge_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_activate_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_deactivate_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_delete_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_execute_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_history_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_load_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_save_route.ts
#	x-pack/plugins/watcher/server/routes/api/watch/register_visualize_route.ts
#	x-pack/plugins/watcher/server/routes/api/watches/register_delete_route.ts
#	x-pack/plugins/watcher/server/routes/api/watches/register_list_route.ts
#	x-pack/plugins/watcher/server/shared_imports.ts
#	x-pack/plugins/watcher/server/types.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:Operations Kibana-Operations Team v7.13.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants