Skip to content

fix(subsequences): stamp empty supplements and unblock exports DEV-2036#6980

Merged
noliveleger merged 2 commits into
release/2.026.12from
dev-2036-fix-empty-supplement-content
May 1, 2026
Merged

fix(subsequences): stamp empty supplements and unblock exports DEV-2036#6980
noliveleger merged 2 commits into
release/2.026.12from
dev-2036-fix-empty-supplement-content

Conversation

@noliveleger
Copy link
Copy Markdown
Contributor

@noliveleger noliveleger commented Apr 30, 2026

📣 Summary

Exports were permanently blocked for some projects due to incomplete NLP supplement records that the migration command could not fix.

👀 Preview steps

  1. ℹ️ Have an asset with QuestionAdvancedFeature records and a SubmissionSupplement with content={} (simulates a crashed revise_data)
  2. 🔴 [on main] Attempt an export — it blocks with SupplementMigrationInProgress; running the management command skips the supplement and does not fix it
  3. 🟢 [on PR] Export proceeds normally; the management command stamps the empty supplement with _version

@noliveleger noliveleger requested review from Guitlle and jnm as code owners April 30, 2026 09:17
@noliveleger noliveleger self-assigned this Apr 30, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR fixes permanently blocked exports caused by SubmissionSupplement records with content={} (created by get_or_create when the subsequent revise_data call crashed). Two targeted changes unblock the path: the export guard now skips empty supplements when checking for un-migrated data, and the management command stamps those empty supplements with _version (instead of silently skipping them) so they are no longer flagged on future runs.

Confidence Score: 5/5

Safe to merge — both changes are minimal, well-scoped, and handle the edge case correctly without introducing new failure paths.

No P0 or P1 issues found. The export guard exclusion is semantically correct (empty supplements have nothing to migrate), and the management command stamping with SCHEMA_VERSIONS[0] is consistent with how the rest of the command treats fully-migrated records. The stranded_qs loop safely handles newly-stamped empty supplements because only the _version key is present and it is already explicitly skipped in the inner loop.

No files require special attention.

Sequence Diagram

sequenceDiagram
    participant User
    participant ExportTask
    participant DB as SubmissionSupplement
    participant MgmtCmd as mgmt cmd

    User->>ExportTask: trigger export
    ExportTask->>DB: check for un-migrated supplements
    alt non-empty supplements without stamp exist
        DB-->>ExportTask: blocked
        ExportTask-->>User: SupplementMigrationInProgress
    else only empty or stamped supplements
        DB-->>ExportTask: clear
        ExportTask->>ExportTask: stream_with_supplements
        ExportTask-->>User: export succeeds
    end

    note over MgmtCmd: Run separately to repair DB
    MgmtCmd->>DB: fetch un-stamped supplements
    loop each supplement
        alt empty content
            MgmtCmd->>MgmtCmd: stamp with latest schema version
        else has data
            MgmtCmd->>MgmtCmd: migrate and stamp
        end
    end
    MgmtCmd->>DB: bulk update stamped records
Loading

Reviews (2): Last reviewed commit: "fix(subsequences): prefix dry-run stamp ..." | Re-trigger Greptile

@noliveleger noliveleger removed request for Guitlle and jnm April 30, 2026 09:41
@rajpatel24 rajpatel24 self-requested a review May 1, 2026 05:56
Copy link
Copy Markdown
Contributor

@rajpatel24 rajpatel24 left a comment

Choose a reason for hiding this comment

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

LGTM

@noliveleger noliveleger merged commit 81055f6 into release/2.026.12 May 1, 2026
20 checks passed
@noliveleger noliveleger deleted the dev-2036-fix-empty-supplement-content branch May 1, 2026 07:12
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