Skip to content

[core.http] Add warning header to deprecated endpoints#205926

Merged
jesuswr merged 16 commits intoelastic:mainfrom
jesuswr:add-warning-header-to-deprecated-endpoints
Jan 20, 2025
Merged

[core.http] Add warning header to deprecated endpoints#205926
jesuswr merged 16 commits intoelastic:mainfrom
jesuswr:add-warning-header-to-deprecated-endpoints

Conversation

@jesuswr
Copy link
Member

@jesuswr jesuswr commented Jan 8, 2025

Summary

resolves #105692

This PR adds a pre response handler that sets a warning header if the requested endpoint is deprecated.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Identify risks

Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.

@jesuswr jesuswr changed the title Add warning header to deprecated endpoints Jan 8, 2025
@jesuswr jesuswr self-assigned this Jan 8, 2025
@jesuswr jesuswr added Feature:http Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes release_note:enhancement and removed release_note:skip Skip the PR/issue when compiling release notes labels Jan 8, 2025
@jesuswr
Copy link
Member Author

jesuswr commented Jan 8, 2025

/ci

1 similar comment
@jesuswr
Copy link
Member Author

jesuswr commented Jan 9, 2025

/ci

@jesuswr jesuswr force-pushed the add-warning-header-to-deprecated-endpoints branch from 3f3e276 to e37ee13 Compare January 10, 2025 13:37
@jesuswr
Copy link
Member Author

jesuswr commented Jan 13, 2025

/ci

1 similar comment
@jesuswr
Copy link
Member Author

jesuswr commented Jan 13, 2025

/ci

@jesuswr jesuswr marked this pull request as ready for review January 13, 2025 16:37
@jesuswr jesuswr requested a review from a team as a code owner January 13, 2025 16:37
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@jesuswr jesuswr requested a review from jloleysens January 13, 2025 16:37
Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Overall looks good! Left a couple of comments that I'd like to get your thoughts on before merging, no major blockers! Ran a simple local test and works as expected.

Great work @jesuswr !

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, but it may be worth adding some kind of truncation mechanism here. I'm not exactly sure how long these might get. Maybe something like 255 chars?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: maybe it's time to pass down env: this.env instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about that, specially if we want to add the buildSha in the warning eventually. Will change it 👍

Comment on lines 252 to 232
Copy link
Contributor

Choose a reason for hiding this comment

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

This does make me wonder if the Kibana response object can rather be given the deprecation info context so that there is only one middleware that injects the warning header 🤔

Don't want to overcomplicate things though, and I think you're test coverage has all paths covered well!

@jesuswr jesuswr force-pushed the add-warning-header-to-deprecated-endpoints branch from d31ba4b to 057833e Compare January 15, 2025 15:46
@jesuswr
Copy link
Member Author

jesuswr commented Jan 17, 2025

@elasticmachine merge upstream

@jesuswr
Copy link
Member Author

jesuswr commented Jan 18, 2025

@elasticmachine merge upstream

/**
* The description message to be displayed for the deprecation.
* This will also appear in the '299 Kibana-{version} {message}' header warning when someone calls the route.
* Keep the message concise to avoid long header values. It is recommended to keep the message under 255 characters.
Copy link
Member Author

Choose a reason for hiding this comment

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

@jloleysens added this comment to address what you mentioned about long header values

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-http-router-server-internal 54 57 +3
Unknown metric groups

API count

id before after diff
@kbn/core-http-router-server-internal 54 57 +3
@kbn/core-http-server 568 569 +1
total +4

History

cc @jesuswr

@jesuswr jesuswr merged commit 0f67c78 into elastic:main Jan 20, 2025
8 checks passed
@jesuswr jesuswr deleted the add-warning-header-to-deprecated-endpoints branch January 20, 2025 12:40
viduni94 pushed a commit to viduni94/kibana that referenced this pull request Jan 23, 2025
## Summary

resolves elastic#105692

This PR adds a pre response handler that sets a warning header if the
requested endpoint is deprecated.

### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

---------

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

Labels

backport:skip This PR does not require backporting Feature:http release_note:enhancement Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v9.0.0

4 participants