Skip to content

[Background Search] Add maxSize to unbounded arrays#253411

Merged
AlexGPlay merged 3 commits intoelastic:mainfrom
AlexGPlay:2808-kbn-team-unbounded-arrays
Feb 19, 2026
Merged

[Background Search] Add maxSize to unbounded arrays#253411
AlexGPlay merged 3 commits intoelastic:mainfrom
AlexGPlay:2808-kbn-team-unbounded-arrays

Conversation

@AlexGPlay
Copy link
Copy Markdown
Contributor

@AlexGPlay AlexGPlay commented Feb 17, 2026

Summary

Updates the schema.arrayOf in background search so they have a maxSize, this way the code scanning alerts from this area get fixed.

Checklist

  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

@AlexGPlay AlexGPlay self-assigned this Feb 17, 2026
schema.literal('expired'),
]),
errors: schema.maybe(schema.arrayOf(schema.string())),
errors: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 10000 })),
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.

in theory we can have as many errors as searches in the background search - I'm just going with the elasticsearch default max here

export const searchSessionsFindSchema = schema.object({
total: schema.number(),
saved_objects: schema.arrayOf(searchSessionSchema),
saved_objects: schema.arrayOf(searchSessionSchema, { maxSize: 10000 }),
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 would be the page size for the management page, by default it's 100 but it can be tweaked with data.search.sessions.management.maxSessions

Comment on lines +75 to +76
schema.object({ id: schema.string(), type: schema.string(), name: schema.string() }),
{ maxSize: 10 }
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.

for this one i'm using a low number just for future proofing because as far as i've seen we don't get references, it's always undefined

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.

Hmm, this is odd, I wonder if we can remove this altogether. I think this might be a bug. Anyway, not important for this PR.

updated_by: schema.maybe(schema.string()),
version: schema.maybe(schema.string()),
namespaces: schema.maybe(schema.arrayOf(schema.string())),
namespaces: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 1 })),
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.

namespaces should always be 1 as defined in the saved object definition:

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.

Mind adding a comment noting that?

),
filter: schema.maybe(schema.string()),
searchFields: schema.maybe(schema.arrayOf(schema.string())),
searchFields: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 10 })),
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.

similar to references i'm going with a low number for future proofing, right now we don't pass down any filter through the _find api so this is not being used

@AlexGPlay AlexGPlay changed the title Add maxSize to unbounded arrays [Background Search] Add maxSize to unbounded arrays Feb 17, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Feb 17, 2026

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Serverless Investigations - Security Solution Cypress Tests #9 / timeline overview search should show all timelines when no search term was entered should show all timelines when no search term was entered

Metrics [docs]

✅ unchanged

History

cc @AlexGPlay

@AlexGPlay AlexGPlay added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// Feature:BackgroundSearch Background search feature used in Discover, Dashboard, etc. labels Feb 17, 2026
@AlexGPlay AlexGPlay marked this pull request as ready for review February 17, 2026 15:49
@AlexGPlay AlexGPlay requested review from a team as code owners February 17, 2026 15:49
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Copy link
Copy Markdown
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

Code LGTM

@AlexGPlay AlexGPlay merged commit 781866b into elastic:main Feb 19, 2026
16 checks passed
ersin-erdal pushed a commit to ersin-erdal/kibana that referenced this pull request Feb 19, 2026
## Summary

Updates the `schema.arrayOf` in background search so they have a
maxSize, this way the code scanning alerts from this area get fixed.


### Checklist

- [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)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.
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:BackgroundSearch Background search feature used in Discover, Dashboard, etc. release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants