Skip to content

[Saved Object Management] Address v1 HTTP API TODOs#150892

Merged
jloleysens merged 8 commits intoelastic:mainfrom
jloleysens:address-som-api-versioning-todos
Feb 16, 2023
Merged

[Saved Object Management] Address v1 HTTP API TODOs#150892
jloleysens merged 8 commits intoelastic:mainfrom
jloleysens:address-som-api-versioning-todos

Conversation

@jloleysens
Copy link
Copy Markdown
Contributor

@jloleysens jloleysens commented Feb 10, 2023

Summary

This PR addresses 4 TODOs identified in #149495. We address these TODOs by taking a closer look at actual use of flagged fields in public code:

  1. FindQueryHTTP['namespaceType']: Probably OK to directly expose this as it seems highly unlikely this value will change soon... We should also be able to version it since it is a well known set.
  2. FindQueryHTTP['search']: looks like it is allowing users to enter any search value against SO attribs. However, this functionality is constrained because it only takes a search term and runs it against a server-side determined search field. The risk is that consumers of the server-side functionality do not keep their default search field up-to-date.
  3. FindQueryHTTP['fields']: Our UI only ever passes in id here. We should consider a follow up PR to add some counter telemetry to track usage of this option and consider removing it entirely.
  4. FindQueryHTTP['sortField']: Lock this down to a well known set of values (probably the riskiest change here).

@jloleysens jloleysens added Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed Feature:Saved Objects Management v8.8.0 labels Feb 10, 2023
@jloleysens jloleysens self-assigned this Feb 10, 2023
Comment on lines +27 to +31
const sortFieldSchema: Type<keyof v1.SavedObjectWithMetadata> = schema.oneOf([
schema.literal('created_at'),
schema.literal('updated_at'),
schema.literal('type'),
]);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is probably the riskiest change to introduce here. The sort columns we define for the front end are pretty much fixed to these values but it is possible for columns to be registered dynamically and attempt to sort by a nested attribute.* field. This seems very unlikely and it does not look like this feature is being used by any other Kibana code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems reasonable to me. In fact, I like the approach that we have pre-defined options for sorting. We do, however, have to consider the case where a type may not have these fields, since we don't have a default option to sort on here.

What do you think about defaulting to type if the other fields are missing? It's unlikely they can be though, so probably not needed.

@jloleysens jloleysens marked this pull request as ready for review February 13, 2023 11:51
@jloleysens jloleysens requested a review from a team as a code owner February 13, 2023 11:51
@elasticmachine
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

Looking good to me (but I'll defer the final review to @TinaHeiligers )

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
savedObjectsManagement 85.2KB 85.2KB -6.0B

History

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

cc @jloleysens

Copy link
Copy Markdown
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +27 to +31
const sortFieldSchema: Type<keyof v1.SavedObjectWithMetadata> = schema.oneOf([
schema.literal('created_at'),
schema.literal('updated_at'),
schema.literal('type'),
]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems reasonable to me. In fact, I like the approach that we have pre-defined options for sorting. We do, however, have to consider the case where a type may not have these fields, since we don't have a default option to sort on here.

What do you think about defaulting to type if the other fields are missing? It's unlikely they can be though, so probably not needed.

@jloleysens jloleysens merged commit ad45020 into elastic:main Feb 16, 2023
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Feb 16, 2023
@jloleysens jloleysens deleted the address-som-api-versioning-todos branch February 16, 2023 11:11
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 backport:skip This PR does not require backporting Feature:Saved Objects Management release_note:skip Skip the PR/issue when compiling release notes Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// v8.8.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants