-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Cases] Deprecate endpoints #124773
[Cases] Deprecate endpoints #124773
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
c7b55e7
to
4ea4cee
Compare
4ea4cee
to
d4d8fe2
Compare
@@ -30,6 +33,9 @@ export function initGetCaseApi({ router, logger }: RouteDeps) { | |||
const id = request.params.case_id; | |||
|
|||
return response.ok({ | |||
headers: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the warning header will be returned on every call to this endpoint - but don't you just want the header if they use the query.includeComments
property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, good point! I will update accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmuellr I just noticed that we default it to true
if the user omits it so I don't think we can distinguish if the user provided the parameter or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, bummer.
You could change the type to boolean | undefined
, and then apply the default outside of the validation, but that's clumsy, and changes your typing which could require more undefined checks. Perhaps instead, since false
is the "deprecated" version, you can just check after the validation if it's false
and then add the header? So it wouldn't be marked deprecated if they used the param and it was true.
Another possibility would be to see if there's a way to get the parameters in more of a "raw" state, after the validation, from the request. And then put the check there.
I really don't think we want this header used every time the API is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pmuellr Amazing idea about the "raw" state. I pushed the changes you suggested.
@@ -27,10 +30,15 @@ export function initGetAllCaseUserActionsApi({ router, logger }: RouteDeps) { | |||
return response.badRequest({ body: 'RouteHandlerContext is not registered for cases' }); | |||
} | |||
|
|||
logger.warn(`The get all cases user actions API '${CASE_USER_ACTIONS_URL}' is deprecated.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukeelmers @kobelb Cases are gonna use these endpoints until we provide alternatives. Is it ok if we log warnings even when Cases are using them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't wanna use logger.warn
for deprecations. "warn" is a high logging level that should be used when things are going seriously awry.
@elastic/kibana-core: did core end up exposing a logger that we should be using for intermittent deprecation usage, for example when a client is calling a HTTP API in a deprecated manner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did core end up exposing a logger that we should be using for intermittent deprecation usage
@kobelb Unfortunately we do not have something like this. There are a few other places in Kibana I am aware of (specifically in Core & Security) where we are logging deprecations for routes at a warn
level.
We have other work we want to do in this area to improve the deprecation process for HTTP APIs:
- [core.http] Support
Warning
headers for deprecated http routes #105692 - Support Kibana deprecation logging in Upgrade Assistant #117241
But to my knowledge we do not have an issue for what you're specifically mentioning here (that is, a dedicated logger exposed to http routes for logging deprecations specifically).
Cases are gonna use these endpoints until we provide alternatives. Is it ok if we log warnings even when Cases are using them?
My main concern would be if we are logging deprecation warnings when users aren't initiating the calls to the deprecated API. I would recommend either adding some logic to try to differentiate between Kibana & non-Kibana requests, or perhaps creating a duplicate route that's just for use by Cases, and simply don't log deprecations from that route.
If you want to attempt to differentiate between Kibana & non-Kibana requests & conditionally log based on that info, there is some prior art in the spaces plugin: https://github.com/elastic/kibana/blob/ec30f2aeeb10fb64b507935e558832d3ef5abfaa/x-pack/plugins/spaces/server/usage_stats/usage_stats_client.ts#L113-L118
This is an imperfect workaround, but will address the majority of situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just dropping by to add another related issue: #112291
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @lukeelmers! I will go with adding some logic to differentiate between Kibana & non-Kibana requests. We plan to introduce different endpoints as alternatives in the future so I will switch Cases to them when the time comes. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's precedent for using the warn
level for this and we haven't had customers complain, feel free to follow suit @cnasikas.
I do agree that we shouldn't be logging these deprecations for internal HTTP requests. One other option we could explore is having /api
public routes and /internal
internal routes, and not doing the deprecation logging for the internal routes.
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't have a way to log these deprecations at the moment, we can proceed with the current PR that includes with the Warning
response header and add logging in a subsequent PR. I don't see any other Kibana HTTP endpoints including the warning response header, but what you have looks fine by me.
@@ -27,10 +30,15 @@ export function initGetAllCaseUserActionsApi({ router, logger }: RouteDeps) { | |||
return response.badRequest({ body: 'RouteHandlerContext is not registered for cases' }); | |||
} | |||
|
|||
logger.warn(`The get all cases user actions API '${CASE_USER_ACTIONS_URL}' is deprecated.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't wanna use logger.warn
for deprecations. "warn" is a high logging level that should be used when things are going seriously awry.
@elastic/kibana-core: did core end up exposing a logger that we should be using for intermittent deprecation usage, for example when a client is calling a HTTP API in a deprecated manner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to the route deprecation LGTM
I don't see any other Kibana HTTP endpoints including the warning response header, but what you have looks fine by me.
I missed this comment earlier, but this is correct -- AFAIK there are no other places where we are manually implementing a Warning
header. This implementation seems fine, however once we are able to address #105692, it will be good to come back and change this implementation to be consistent with our long-term solution.
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: cc @cnasikas |
Thank you @lukeelmers! Yes, when core supports it we will come back and change it. |
💔 All backports failed
How to fixRe-run the backport manually:
Questions ?Please refer to the Backport tool documentation |
Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit eb7591b) # Conflicts: # x-pack/plugins/cases/server/routes/api/stats/get_status.ts
Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit eb7591b) # Conflicts: # x-pack/plugins/cases/server/routes/api/stats/get_status.ts
Summary
This PR deprecates the following Cases endpoints:
includeComments
query parameter.It follows the recommendations specified in: #105692
Checklist
Delete any items that are not applicable to this PR.
For maintainers
Release notes
The following Cases API endpoints are deprecated:
The
includeComments
query parameter of the GET /api/cases/{case_id} endpoint is deprecated.