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

[API Deprecations] Skip HTTP resources #207725

Closed

Conversation

afharo
Copy link
Member

@afharo afharo commented Jan 22, 2025

Summary

Follow up to #199026
Related to #199616

When working on #199616, we noticed that we counted (and now logged) all the APIs serving http-resources (like the /bundles/ routes).

This PR improves our filter to avoid counting and logging those ones (they pass the current filters because they are not categorized as public, and they are technically not called internally (the browser loads them without the internal header).

@afharo afharo requested a review from a team as a code owner January 22, 2025 10:51
@afharo afharo self-assigned this Jan 22, 2025
@afharo afharo added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels Jan 22, 2025
@elasticmachine
Copy link
Contributor

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

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.

Did not test locally, but changes make sense to me!

The only part that I'm not quite following in this description is:

they pass the current filters because they are not categorized as public

When we register HTTP resources we categorize them explicitly as public to avoid triggering the "internal" access deprecation (and bc they are a special version of "public"). But maybe there is a code path for some of these registrations that does not preserve that?

@jloleysens
Copy link
Contributor

Also, in our testing, I do not recall seeing any HTTP resource deprecations being surfaced 🤔 , I expect they are now appearing in Upgrade Assistant (which definitely is a bug).

Copy link
Member

@Bamieh Bamieh left a comment

Choose a reason for hiding this comment

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

I am fine with this change. Although it might be better to tailor this during logging rather than tinkering with the getIsAccessApiDeprecation conditions.

Feel free to merge this PR however I think its better to add this condition in an if statement wrapping the logging instead of changing the getIsAccessApiDeprecation. Having this extra if statement is leading to the same behavior in the deprecations. But from a code maintenance POV its redundant code that might restrict our implementation in the future if we happen to want to change things for access api deprecation.

@jloleysens

I expect they are now appearing in Upgrade Assistant (which definitely is a bug).

No they do not appear in the UA because the “public” route definition omits them. i did test for that as well when i was working in this area
Code here https://github.com/elastic/kibana/blob/main/src/core/packages/http/router-server-internal/src/route.ts#L167-L175

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #15 / HoverableAvatar renders the tooltip when hovering

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-server 243 244 +1
Unknown metric groups

API count

id before after diff
@kbn/core-http-server 569 570 +1

cc @afharo

function getPostValidateEventMetadata(
request: AnyKibanaRequest,
routeInfo: RouteInfo
): PostValidationMetadata {
return {
deprecated: routeInfo.deprecated,
isInternalApiRequest: request.isInternalApiRequest,
isPublicAccess: isPublicAccessApiRoute(routeInfo),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
isPublicAccess: isPublicAccessApiRoute(routeInfo),
isPublicAccess: routeInfo.access === 'public'

On alternative to the proposed changes is to preserve the previous behaviour instead of the using/fixing isPublicAccessApiRoute here.

@afharo
Copy link
Member Author

afharo commented Jan 22, 2025

Superseded by #207829. Closing

@afharo afharo closed this Jan 22, 2025
@afharo afharo deleted the api-deprecations/skip-http-resources branch January 22, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants