fix #244: remove @dataclass from MigrationError #266

Merged
Mark merged 1 commit from fix/mesh-seed-244-dataclass-migrationerror into master 2026-08-04 17:06:34 +00:00
Owner

Summary

Remove @dataclass decorator from MigrationError(Exception) in substrate/ledger/migrations.py:118.

Problem

MigrationError base class is decorated with @dataclass, which generates an __init__ that accepts only self. Subclasses (MigrationDriftError, UnknownMigrationError, ChecksumMismatchError) call super().__init__(message), which fails with:

TypeError: MigrationError.__init__() takes 1 positional argument but 2 were given

This breaks drift detection — db_migrate verify raises TypeError instead of MigrationDriftError.

Fix

Remove the @dataclass decorator. The subclasses set instance attributes manually already.

Verification

from substrate.ledger.migrations import MigrationDriftError
try:
    raise MigrationDriftError(checksum="abc", applied_sql="SELECT 1")
except MigrationDriftError:
    print("Fixed — drift detection works")

Closes #244

## Summary Remove `@dataclass` decorator from `MigrationError(Exception)` in `substrate/ledger/migrations.py:118`. ## Problem `MigrationError` base class is decorated with `@dataclass`, which generates an `__init__` that accepts only `self`. Subclasses (`MigrationDriftError`, `UnknownMigrationError`, `ChecksumMismatchError`) call `super().__init__(message)`, which fails with: ``` TypeError: MigrationError.__init__() takes 1 positional argument but 2 were given ``` This breaks drift detection — `db_migrate verify` raises TypeError instead of MigrationDriftError. ## Fix Remove the `@dataclass` decorator. The subclasses set instance attributes manually already. ## Verification ```python from substrate.ledger.migrations import MigrationDriftError try: raise MigrationDriftError(checksum="abc", applied_sql="SELECT 1") except MigrationDriftError: print("Fixed — drift detection works") ``` Closes #244
fix #244: remove @dataclass from MigrationError to restore exception protocol
Some checks failed
CI / Lint and Format (pull_request) Failing after 30s
CI / Security Check (pull_request) Failing after 49s
CI / Code Quality Checks (pull_request) Successful in 8s
CI / Type Check (pull_request) Successful in 1m12s
CI / Unit Tests (pull_request) Failing after 34s
CI / Full Test Suite (pull_request) Has been skipped
CI / Smoke Tests (pull_request) Failing after 31s
CI / Integration Tests (pull_request) Successful in 1m7s
07abae279d
The @dataclass decorator on MigrationError(Exception) generated an __init__
that accepted only self, breaking subclasses (MigrationDriftError,
UnknownMigrationError, ChecksumMismatchError) that call super().__init__(message).

This caused drift detection to raise TypeError instead of MigrationDriftError,
rendering the db_migrate verify CLI path broken.

Fix: remove the @dataclass decorator from line 118.
Mark merged commit 134c00c33f into master 2026-08-04 17:06:34 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/mesh-seed!266
No description provided.