Skip to content

Fix extractors being deleted when an input is started or stopped#26198

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

Fix extractors being deleted when an input is started or stopped#26198
kodjo-anipah merged 2 commits into
masterfrom
fix/input-save-deletes-extractors

Conversation

@patrickmann

@patrickmann patrickmann commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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.

patrickmann and others added 2 commits June 2, 2026 16:04
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>

This comment was marked as resolved.

@patrickmann patrickmann marked this pull request as ready for review June 2, 2026 14:59
@patrickmann patrickmann requested a review from a team June 2, 2026 15:00
@kodjo-anipah kodjo-anipah self-assigned this Jun 3, 2026
@kodjo-anipah kodjo-anipah self-requested a review June 3, 2026 07:51
@kodjo-anipah kodjo-anipah removed their assignment Jun 3, 2026
saveWithoutEvents(updatedInput);
// Use a targeted update instead of saving the whole input to avoid overwriting concurrent changes
// to other parts of the input document.
collection.updateOne(

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.

Good catch

@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.

Thanks for fixing this

@kodjo-anipah kodjo-anipah merged commit dbc747f into master Jun 3, 2026
26 checks passed
@kodjo-anipah kodjo-anipah deleted the fix/input-save-deletes-extractors branch June 3, 2026 08:40
kodjo-anipah pushed a commit that referenced this pull request Jun 3, 2026
…1`) (#26203)

* Fix extractors being deleted when an input is started or stopped (#26198)

* 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)

* Remove backported extractor regression tests from 7.1 branch

---------

Co-authored-by: Patrick Mann <patrickmann@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dennisoelkers pushed a commit that referenced this pull request Jun 4, 2026
)

* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input Extractors Deleted When Input Started/Stopped

3 participants