Skip to content

[fix] Resolve broken workflow revision versions since release/v0.84.0#4639

Open
junaway wants to merge 3 commits into
release/v0.103.3from
fix/broken-revision-versions-since-0-84-0-migration
Open

[fix] Resolve broken workflow revision versions since release/v0.84.0#4639
junaway wants to merge 3 commits into
release/v0.103.3from
fix/broken-revision-versions-since-0-84-0-migration

Conversation

@junaway

@junaway junaway commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Repair workflow revision version data caused by the release/v0.84.0 migration missing synthetic v0 workflow revisions.

The migration does three things:

  1. Adds missing v0 workflow revisions for workflow variants that do not have one.
  2. Re-stretches workflow revision versions only for workflow variants that currently have duplicate workflow revision versions.
  3. Updates embedded environment revision data references whose referenced workflow revision version changed.

Why

The legacy apps migration copied existing apps data into workflow_revisions but did not create the expected seed v0 workflow revision.

For workflow variant missing v0, later commits can compute a workflow revision version that already exists, producing duplicate workflow revision versions. This is data corruption, not an active commit race condition.

Refs

This PR supersedes this other PR.

Copilot AI review requested due to automatic review settings June 11, 2026 12:24
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jun 12, 2026 4:23pm

Request Review

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. Bug Report Something isn't working labels Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9dd99346-c954-48e6-a75a-c547f8e31b8c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces a data migration that repairs workflow revision versions in PostgreSQL by seeding missing v0 rows, correcting misaligned duplicate versions, and updating environment revision JSON references to match. The migration is deployed via both OSS and EE Alembic entry points.

Changes

Workflow Revision Version Repair

Layer / File(s) Summary
Data migration core setup and utilities
api/oss/databases/postgres/migrations/core/data_migrations/workflow_revision_versions.py
Defines imports, batch size constant, and a UUIDv7-like helper that converts timezone-aware datetimes to UUID values for ID generation.
Missing v0 seed insertion
api/oss/databases/postgres/migrations/core/data_migrations/workflow_revision_versions.py
Query helper identifies variants missing version '0', and insertion logic creates seed v0 rows with computed timestamps and generated UUIDs.
Duplicate version repair
api/oss/databases/postgres/migrations/core/data_migrations/workflow_revision_versions.py
Query helpers detect variants with duplicate/misaligned versions and fetch revisions in chronological order; repair logic reassigns each revision's version to match its positional index in the sequence.
Environment revision reference rewriting
api/oss/databases/postgres/migrations/core/data_migrations/workflow_revision_versions.py
Temporary table stores and batches revision-id-to-version mappings; helper function identifies affected environment revisions and rebuilds their JSON references with corrected version values using JSONB operations.
Migration orchestration and downgrade
api/oss/databases/postgres/migrations/core/data_migrations/workflow_revision_versions.py
Main upgrade function orchestrates v0 seeding and duplicate repair in batches with transaction commits; downgrade raises NotImplementedError to block rollback.
Alembic migration entry points
api/oss/databases/postgres/migrations/core/versions/b3c4d5e6f7a9_repair_workflow_revision_versions.py, api/ee/databases/postgres/migrations/core/versions/b3c4d5e6f7a9_repair_workflow_revision_versions.py
OSS and EE migration files define Alembic revision metadata and wire upgrade()/downgrade() to delegate to the shared data migration functions via the active database connection.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: resolving broken workflow revision versions from the v0.84.0 release.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose, rationale, and three specific actions of the migration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/broken-revision-versions-since-0-84-0-migration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@junaway junaway changed the title [fix] Resolve broken revision versions since release/v0.84.0 [fix] Resolve broken workflow revision versions since release/v0.84.0 Jun 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an Alembic data migration to repair corrupted workflow_revisions.version data introduced around release/v0.84.0, by (a) inserting missing synthetic v0 revisions, (b) re-numbering versions for affected variants, and (c) rewriting embedded environment_revisions.data.references[*].*_revision.version values when versions change.

Changes:

  • Adds a new OSS/EE Alembic migration revision (b3c4d5e6f7a9) that runs the repair.
  • Implements the repair logic in a new OSS data migration module that seeds missing v0 rows, re-stretches revision versions in batches, and updates environment references accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
api/oss/databases/postgres/migrations/core/versions/b3c4d5e6f7a9_repair_workflow_revision_versions.py Adds the OSS Alembic migration entrypoint wiring upgrade()/downgrade() to the new data migration.
api/oss/databases/postgres/migrations/core/data_migrations/workflow_revision_versions.py Implements the batch seeding + version repair + environment reference rewrite logic.
api/ee/databases/postgres/migrations/core/versions/b3c4d5e6f7a9_repair_workflow_revision_versions.py Adds the EE Alembic migration entrypoint mirroring OSS and reusing the OSS data migration implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 99a34408-f7bc-4cc7-955e-10a00a3fb727

📥 Commits

Reviewing files that changed from the base of the PR and between 787ed8b and 90731d6.

📒 Files selected for processing (3)
  • api/ee/databases/postgres/migrations/core/versions/b3c4d5e6f7a9_repair_workflow_revision_versions.py
  • api/oss/databases/postgres/migrations/core/data_migrations/workflow_revision_versions.py
  • api/oss/databases/postgres/migrations/core/versions/b3c4d5e6f7a9_repair_workflow_revision_versions.py

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-production-4c7d.up.railway.app/w
Image tag pr-4639-c00e4c2
Status Failed
Railway logs Open logs
Logs View workflow run
Updated at 2026-06-12T16:46:27.979Z

@bekossy bekossy changed the base branch from main to release/v0.103.3 June 12, 2026 16:21
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Report Something isn't working lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants