Skip to content

Fix extractors being deleted when an input is started or stopped (7.1)#26203

Merged
kodjo-anipah merged 2 commits into
7.1from
backport-7.1/fix/input-save-deletes-extractors
Jun 3, 2026
Merged

Fix extractors being deleted when an input is started or stopped (7.1)#26203
kodjo-anipah merged 2 commits into
7.1from
backport-7.1/fix/input-save-deletes-extractors

Conversation

@graylog-internal-actions-access

@graylog-internal-actions-access graylog-internal-actions-access Bot commented Jun 3, 2026

Copy link
Copy Markdown

Note: This is a backport of #26198 to 7.1.
In the interest of time and keeping the backport focused, it drops the new regression tests: they depend on InputServiceImpl.extractorCountByInputId which is not part of 7.1 or this cherry-pick.

Closes #26009

Description

Since 7.1.0, extractors were deleted whenever an input was started, stopped, or updated. This was a regression from the PersistedImpl to AutoValue migration of InputImpl (#24057): the new entity did not model the embedded extractors array, so loading an input silently discarded its extractors, and saving via replaceOne then persisted the loss by replacing the whole document. Starting/stopping an input triggers such a save since #25338 (persistDesiredState), and updating an input had the same effect through the getFields() merge in InputsResource.

Fixed by modeling the embedded extractor documents on InputImpl (analogous to the embedded static fields) so they survive full document round-trips, carrying them through getFields() and buildFromMap(), and turning persistDesiredState() into a targeted update of the desired_state field so state changes no longer rewrite the whole document.

Verified that we did not perform any other such migrations in 7.1.

How Tested

  • New regression tests in InputServiceImplTest: persistDesiredStateKeepsExtractors, saveKeepsExtractors, updateViaFieldsMapKeepsExtractors
  • Extended the persistedDocumentContainsOnlyExpectedFields contract test to cover the extractors field

Manual testing: create an input, add an extractor to it, then stop and start the input from the Inputs page. The extractor must still be listed afterwards. Also edit the input (e.g. change the title) and save, then verify the extractor is still present.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

)

* Fix extractors being deleted when an input is started or stopped

The PersistedImpl -> AutoValue migration of InputImpl (#24057) dropped
the embedded extractors array from the entity model: the builder ignores
unknown properties, so loading an input discards its extractors, and
saving uses replaceOne, which then persists the loss by replacing the
whole document.

Starting or stopping an input persists the desired state on the input
document since #25338, so every start/stop deleted all extractors of the
input. Updating an input through the REST API had the same effect via
the getFields() merge in InputsResource, which also omitted extractors.

Fix this by modeling the embedded extractor documents on InputImpl (like
the embedded static fields) so they survive full document round-trips,
and by carrying them through getFields() and buildFromMap(). Also turn
persistDesiredState() into a targeted update of the desired_state field
so state changes no longer rewrite the whole document.

Fixes #26009

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* CL

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit dbc747f)
@patrickmann patrickmann marked this pull request as ready for review June 3, 2026 09:40

@kodjo-anipah kodjo-anipah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@kodjo-anipah kodjo-anipah merged commit a2c8829 into 7.1 Jun 3, 2026
25 checks passed
@kodjo-anipah kodjo-anipah deleted the backport-7.1/fix/input-save-deletes-extractors branch June 3, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants