Skip to content

fix: keep error state of previous task attempt (MAPCO-11442) - #104

Merged
almog8k merged 2 commits into
masterfrom
fix/keep-previous-attempt-errors-MAPCO-11442
Aug 30, 2026
Merged

almog8k merged 2 commits into
masterfrom
fix/keep-previous-attempt-errors-MAPCO-11442

Conversation

@almog8k

@almog8k almog8k commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor
Question Answer
Bug fix ✔
New feature ✖
Breaking change ✖
Deprecations ✖
Documentation ✖
Tests added ✔
Chore ✖

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

errorsSummary is persisted on every saveState next to processingState, but only processingState was 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 — hence isValid: true, a zeroed errorsSummary, and a report.* shapefile deleted by finalize().

Fix

ValidationErrorCollector.restoreErrorsSummary() seeds the counters and thresholds from the persisted summary, copying each nested object since updateThresholdsTracking mutates smallHoles.count in place. IngestionJobHandler calls it before readAndProcess, only when a processingState exists — 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. invalidFeaturesMap is intentionally not restored: the previous attempt already wrote its error features to report.shp, which this fix stops finalize() from deleting.

Tests

  • validationErrorCollector.spec.ts — restore, accumulate on top, no mutation of the source, prior criticals stay critical.
  • ingestionHandler.spec.ts — resumed task yields isValid: false; fresh task ignores the persisted summary.
  • validationTaskFlow.spec.ts — end-to-end resume; verified it fails on isValid: true with the fix reverted.

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.
@almog8k
almog8k merged commit c885158 into master Aug 30, 2026
5 checks passed
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.

2 participants