Skip to content

improvement: make endpoint migration previews diffable and writes atomic - #45

Closed
mojtaba-arvin wants to merge 28 commits into
mainfrom
improve/migration-preview-safe-write
Closed

mojtaba-arvin wants to merge 28 commits into
mainfrom
improve/migration-preview-safe-write

Conversation

@mojtaba-arvin

@mojtaba-arvin mojtaba-arvin commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Make the endpoint migration command safe, deterministic, and explicit about work it cannot perform.

  • Keep dry-run as the default and make --write, --dry-run, and --diff mutually exclusive.
  • Add a unified diff preview with repository-relative paths.
  • Apply each changed file using same-directory atomic replacement, preserving permission bits and cleaning temporary files.
  • Sort file discovery so previews and writes are deterministic.
  • Report every visibly legacy decorator that cannot be rewritten with its relative path, line number, and specific reason (dynamic values, positional versions, duplicate/conflicting flags, **kwargs, comments, or parse failures).
  • Recognize imported aliases of the package's public endpoint decorator so those legacy calls are not silently missed.
  • Keep skipped occurrences separate from successful rewrite hunks in --diff, and report rewrite/skip totals.
  • On a write failure, raise a clear CommandError identifying the failed file and listing earlier files already updated. The command explicitly documents that atomicity is per file, not a transaction across the directory.
  • Add tests for unsupported forms, imported aliases, deterministic ordering, diff reporting, syntax errors, and a multi-file partial-write failure.
  • Update the Reference documentation to describe the actual safety contract.

Cross-PR coordination

Removed the endpoint-removal/OpenAPI feature claim from docs/README.md on this branch (restored it to the current main version). That claim remains with PR #44, which contains the implementation and consumer example. This PR therefore no longer depends on PR #44's merge order.

Verification

Latest head: aab322b0c3aaac1667b03c9d1fa64c1c2075fdc5.

Full CI passed.

The exact head passed the full pull-request gate: unit/integration tests, lint, package build, website verification, Windows and macOS jobs, and every configured Python/Django tox environment. CodeQL also passed. Run: https://github.com/mojtaba-arvin/django-api-versioning/actions/runs/44356748138

PR remains Draft pending final cross-PR review; no merge or ready-for-review action has been taken.

Copy link
Copy Markdown
Owner Author

Cross-PR review note before this draft is advanced:

The full CI gate and both CodeQL languages now pass on 24c47139cc2ea9099a54748a918015f30b624a65, including macOS and Windows. This is good verification of the current scope, but it does not close the cross-PR documentation dependency or the follow-up safety/UX gaps.

Copy link
Copy Markdown
Owner Author

Follow-up from the cross-PR audit: I removed the unrelated docs/README.md OpenAPI/endpoint-removal claim from this branch and restored that file exactly to the current main blob. The feature claim now stays with PR #44, which contains the implementation and consumer example changes. This avoids both bad merge orders: PR #45 no longer advertises an unmerged feature if it lands first, and it cannot revert PR #44's documentation if #44 lands first.

Commit: b46e18d8c14c33b5cb4d8e845dd2c3aaba675db3.

CI for this new head is still pending; I will treat the earlier passing runs as evidence only for the previous SHA.

Copy link
Copy Markdown
Owner Author

Superseded by the consolidated integration PR #58, which includes this work and passed the complete required PR gate on exact head 98f79472777f9e8e0bbf78c16531d97a46ad0a3a. The consolidated change is now merged to main as a8b39343c478bb5a8afbe1de20d95a2b10630f37. Closing this focused PR to avoid leaving duplicate, already-integrated branches open; its implementation history remains in the PR conversation and the consolidated merge.

@mojtaba-arvin
mojtaba-arvin deleted the improve/migration-preview-safe-write branch November 19, 2026 09:35
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.

1 participant