Repository navigation
fix: keep error state of previous task attempt (MAPCO-11442) - #104
Merged
Merged
Conversation
Move createFakeErrorsSummary out of the shapefileReportWriter data file into tests/unit/mocks/errorsSummaryMocks.ts, so error summary fixtures live in one place instead of being imported across test folders. Add the emptyErrorsSummary and errorsSummaryWithErrors constants, a createResumedValidationTask task mock, and an errorsSummary option on the integration createTask factory.
The validation error collector only lived in memory for a single processJob run. Its aggregated state was persisted to the task parameters on every saveState, next to the processing state, but only the processing state was restored when a task resumed. On a retry the shapefile reader therefore skipped every chunk that was already processed, their errors were never collected again, and the collector started from zero. As a result hasCriticalErrors returned false, the task was updated with isValid true, the persisted errors summary was overwritten with zeroes and the partially written report shapefile was deleted. Restore the persisted errors summary into the collector when the task carries a processing state, so errors of the current attempt accumulate on top of the previous ones. The threshold percentages stay correct because the shapefile stats always cover the whole file.
CL-SHLOMIKONCHA
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues: MAPCO-11442
Further information:
Problem
A validation task that should have failed was reported as passed, because the error state of the previous attempt was lost.
Root cause
errorsSummaryis persisted on everysaveStatenext toprocessingState, but onlyprocessingStatewas restored on resume. On a retry the reader skips the chunks it already processed, so their errors are never re-collected and the collector starts at zero — henceisValid: true, a zeroederrorsSummary, and areport.*shapefile deleted byfinalize().Fix
ValidationErrorCollector.restoreErrorsSummary()seeds the counters and thresholds from the persisted summary, copying each nested object sinceupdateThresholdsTrackingmutatessmallHoles.countin place.IngestionJobHandlercalls it beforereadAndProcess, only when aprocessingStateexists — the same resume marker, always persisted together with the summary — so a task starting from scratch is unaffected.Threshold percentages stay correct because the shapefile stats cover the whole file.
invalidFeaturesMapis intentionally not restored: the previous attempt already wrote its error features toreport.shp, which this fix stopsfinalize()from deleting.Tests
validationErrorCollector.spec.ts— restore, accumulate on top, no mutation of the source, prior criticals stay critical.ingestionHandler.spec.ts— resumed task yieldsisValid: false; fresh task ignores the persisted summary.validationTaskFlow.spec.ts— end-to-end resume; verified it fails onisValid: truewith the fix reverted.