Skip to content

feat: add provider downgrade command (PRA-226)#16

Open
tngotr wants to merge 2 commits intomainfrom
feature/pra-226-provider-migration-framework
Open

feat: add provider downgrade command (PRA-226)#16
tngotr wants to merge 2 commits intomainfrom
feature/pra-226-provider-migration-framework

Conversation

@tngotr
Copy link
Contributor

@tngotr tngotr commented Mar 5, 2026

Summary

  • Add pragma providers downgrade <provider> --version X.Y.Z command with confirmation prompt
  • Align upgrade command confirmation prompt to be specific (matches downgrade style)
  • Error handling for 404 (not installed), 409 (already on version), 422 (version chain broken)

Depends On

  • pragma-sdk#14 (merge first)

Test Plan

  • task test — 203 passed
  • Tests for success, already_on_version (409), not_installed (404), version_chain_broken (422)

Summary by CodeRabbit

  • New Features
    • Added a downgrade command for providers with target version specification and confirmation prompt
    • Enhanced upgrade confirmation prompts to display provider name and target version
    • Improved error handling for version-related operations, including invalid version chains and installation status checks

tngotr added 2 commits March 5, 2026 16:23
Add downgrade command to complement the existing upgrade command.
Requires explicit --version/-v flag (no "latest" concept for downgrade).
Handles 404/409/422 errors with user-friendly messages.
Change from generic "Proceed with upgrade?" to "Upgrade {name} to v{target}?"
matching the downgrade prompt pattern "Downgrade {name} to v{version}?".
@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 43f6fb53-6338-4811-8cec-3bfdcb7c8157

📥 Commits

Reviewing files that changed from the base of the PR and between c1e88a5 and 247e69c.

📒 Files selected for processing (2)
  • src/pragma_cli/commands/providers.py
  • tests/test_providers.py

📝 Walkthrough

Walkthrough

A new downgrade command was added to the CLI for managing provider versions, with error handling for not-installed, already-on-version, and invalid-version-chain scenarios. The upgrade command's confirmation prompt was made provider-specific. Comprehensive tests cover success and error cases.

Changes

Cohort / File(s) Summary
Downgrade Command Implementation
src/pragma_cli/commands/providers.py
Added new downgrade command with provider name and target version parameters, including authentication checks, user confirmation prompts, and error handling for 404, 409, and 422 HTTP responses. Updated upgrade confirmation prompt to include provider-specific details.
Downgrade Command Tests
tests/test_providers.py
Added four test cases covering successful downgrades, 409 "already on version" errors, 404 "not installed" errors, and 422 "version chain broken" errors, mirroring existing upgrade test patterns.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI Command
    participant Auth as Auth Check
    participant Prompt as User Prompt
    participant Client as Client
    participant API as API/Server
    
    User->>CLI: downgrade provider v1.0.0
    CLI->>Auth: _require_auth()
    Auth-->>CLI: authenticated
    
    CLI->>Prompt: "Upgrade {name} to v{target}?"
    Prompt-->>User: confirmation needed
    User-->>Prompt: yes/--yes flag
    
    CLI->>Client: client.downgrade_provider(name, target_version)
    Client->>API: POST downgrade request
    
    alt Success
        API-->>Client: 200 OK + new version
        Client-->>CLI: success response
        CLI-->>User: "Downgraded to v{version}"
    else Not Installed (404)
        API-->>Client: 404 Not Found
        Client-->>CLI: error
        CLI-->>User: exit 1, "not installed"
    else Already on Version (409)
        API-->>Client: 409 Conflict
        Client-->>CLI: error
        CLI-->>User: exit 1, "already on v{version}"
    else Invalid Version Chain (422)
        API-->>Client: 422 Unprocessable
        Client-->>CLI: error
        CLI-->>User: exit 1, "version chain" error + diagnostic
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A downgrade so grand, a hop back in time,
Through versions we travel, each one so sublime,
With errors caught wisely, no chain left behind,
This feature's a treasure, both tested and refined! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding a new provider downgrade command, which is the primary focus of both the implementation and test changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/pra-226-provider-migration-framework

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

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