Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow any type for customResponseHeaders config #66689

Merged

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented May 15, 2020

Summary

Fix #66146

Change http.customResponseHeaders validation to allow any type of values (as it was done prior to 7.6.0) and convert them to strings or array of strings

Checklist

@pgayvallet pgayvallet added v7.7.1 v7.8.0 Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels May 15, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

Comment on lines +178 to +180
const convertHeader = (entry: any): string => {
return typeof entry === 'object' ? JSON.stringify(entry) : String(entry);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To get exactly the previous behavior back, while keeping the headers conversion logic inside core instead of delegating it to hapi as it was done in legacy (where any type of value were sent as headers, letting hapi handle the conversion), I had to use this mixed JSON.stringify + String(of) approach.

Tell me if this can be improved.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to avoid breaking the previous behavior.

@@ -153,7 +153,15 @@ export class HttpConfig {
this.host = rawHttpConfig.host;
this.port = rawHttpConfig.port;
this.cors = rawHttpConfig.cors;
this.customResponseHeaders = rawHttpConfig.customResponseHeaders;
this.customResponseHeaders = Object.entries(rawHttpConfig.customResponseHeaders ?? {}).reduce(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lot of tests are using partials of the config. I tried to fix them, but adding customResponseHeaders: {} in some was breaking snapshots or even assertions about the received config, so I choose to add this ?? {} to avoid breaking tests.

@pgayvallet pgayvallet marked this pull request as ready for review May 15, 2020 15:19
@pgayvallet pgayvallet requested a review from a team as a code owner May 15, 2020 15:19
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@pgayvallet pgayvallet merged commit 91ed1dd into elastic:master May 15, 2020
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request May 15, 2020
* allow any type of value for customResponseHeaders and convert them

* fix test config creation

* add `?? {}` to avoid breaking all tests...
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request May 15, 2020
* allow any type of value for customResponseHeaders and convert them

* fix test config creation

* add `?? {}` to avoid breaking all tests...
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request May 15, 2020
* allow any type of value for customResponseHeaders and convert them

* fix test config creation

* add `?? {}` to avoid breaking all tests...
pgayvallet added a commit that referenced this pull request May 15, 2020
* allow any type of value for customResponseHeaders and convert them

* fix test config creation

* add `?? {}` to avoid breaking all tests...
pgayvallet added a commit that referenced this pull request May 16, 2020
* allow any type of value for customResponseHeaders and convert them

* fix test config creation

* add `?? {}` to avoid breaking all tests...
pgayvallet added a commit that referenced this pull request May 16, 2020
* allow any type of value for customResponseHeaders and convert them

* fix test config creation

* add `?? {}` to avoid breaking all tests...
jloleysens added a commit that referenced this pull request May 18, 2020
…ine-editor

* 'master' of github.com:elastic/kibana: (157 commits)
  [ML] fix url assertion (#66850)
  Skip failing lens test(s). #66779
  [SOM] Preserve saved object references when saving the object (#66584)
  Use ES API from start contract (#66157)
  Reorganize Management apps into Ingest, Data, Alerts and Insights, Security, Kibana, and Stack groups (#65796)
  [Uptime] Fix flaky navigation to certs page in tests (#66806)
  [Maps] Do not check count for blended layers when layer is not visible (#66460)
  [SIEM] Fixes glob patterns from directory changes recently for GraphQL
  chore(NA): bump static-fs to 1.0.2 (#66775)
  [Maps] Handle cross cluster index _settings resp (#66797)
  [SIEM][Lists] Adds 90% of the REST API and client API for exception lists and exception items
  allow any type for customResponseHeaders config (#66689)
  [APM] Disable map layout animation (#66763)
  [ML] Add linking to dataframe from job management tab (#65778)
  [Maps] Get number of categories from palette (#66454)
  move oss features registration to KP (#66524)
  [kbn/plugin-helpers] typescript-ify (#66513)
  Add kibana-operations as codeowners for .ci/es-snapshots and vars/ (#66746)
  FTR: move basic services under common folder (#66563)
  Migrate Beats Management UI to KP (#65791)
  ...

# Conflicts:
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_form/pipeline_form.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_form/pipeline_form_fields.tsx
gmmorris added a commit to gmmorris/kibana that referenced this pull request May 18, 2020
* master:
  [ML] fix url assertion (elastic#66850)
  Skip failing lens test(s). elastic#66779
  [SOM] Preserve saved object references when saving the object (elastic#66584)
  Use ES API from start contract (elastic#66157)
  Reorganize Management apps into Ingest, Data, Alerts and Insights, Security, Kibana, and Stack groups (elastic#65796)
  [Uptime] Fix flaky navigation to certs page in tests (elastic#66806)
  [Maps] Do not check count for blended layers when layer is not visible (elastic#66460)
  [SIEM] Fixes glob patterns from directory changes recently for GraphQL
  chore(NA): bump static-fs to 1.0.2 (elastic#66775)
  [Maps] Handle cross cluster index _settings resp (elastic#66797)
  [SIEM][Lists] Adds 90% of the REST API and client API for exception lists and exception items
  allow any type for customResponseHeaders config (elastic#66689)
  [APM] Disable map layout animation (elastic#66763)
  [ML] Add linking to dataframe from job management tab (elastic#65778)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:fix Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.7.1 v7.8.0 v7.9.0
Projects
None yet
4 participants