You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds provider.LockProvider and provider.LockProviderNamed in pkg/provider/operationlock.go. Each acquires the provider operation lock and returns an unlock func. Migrates 9 duplicated GetProviderOperationLock -> Lock() -> defer Unlock() sites to them. Error strings are byte-identical.
Why
Nine call sites repeated the same 9-line lock block with the same error wrapping. The for <name> variant is kept only where it already existed (add.go, rename.go), via LockProviderNamed.
Skipped pkg/workspace/provider_update.go: it returns the get-lock error bare, so migrating would add a get operation lock: prefix and change error text.
Validation
mise run cli:format: no changes
mise run cli:lint:ci: 0 issues
go build ./...: ok
go vet on pkg/provider, cmd/provider, cmd/pro, cmd/mcp, pkg/workspace: clean
go test -count=1 ./pkg/provider/... ./cmd/provider/... ./cmd/pro/... ./cmd/mcp/... ./pkg/workspace/...: all ok
Eligible: yes. Behaviour-preserving, no go.mod/go.sum, workflow, lint config, secret, or credential/auth changes, and no tests removed or weakened.
Summary by CodeRabbit
Reliability
Provider management commands now use consistent locking when adding, updating, deleting, renaming, initializing, selecting, or changing provider settings. This helps coordinate simultaneous operations on providers and ensures locks are released when commands finish or encounter an error.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 21b03dbb-50c3-4de6-acae-10f65afd08f5
📥 Commits
Reviewing files that changed from the base of the PR and between e0fe773 and 980706a.
📒 Files selected for processing: 11
cmd/mcp/tools_provider.go
cmd/pro/update_provider.go
cmd/provider/add.go
cmd/provider/delete.go
cmd/provider/init.go
cmd/provider/rename.go
cmd/provider/set.go
cmd/provider/set_source.go
cmd/provider/use.go
pkg/provider/operationlock.go
pkg/provider/operationlock_test.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
📝 Walkthrough
Provider operation-lock acquisition is now handled by shared helper functions. Provider commands use those helpers and defer the returned unlock callbacks. Tests cover lock lifetime and errors for invalid provider names.
Added LockProvider and LockProviderNamed to acquire operation locks and return unlock callbacks. Tests check lock lifetime, invalid-name errors, and name context.
The provider lock refactor has no identified merge-blocking issue and is ready to merge after normal checks.
Security architecture risk:⚪ Minimal · up to 98070
The shared helpers preserve the existing provider-name validation, lock identity, acquisition order, release timing, and error behavior. The reviewed changes do not expand tool authority or weaken provider-operation serialization. No introduced or worsened security concern was identified.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The changed synchronization contract affects existing provider lifecycle operations addressed by context and provider name. The inspected MCP path retains the same tool input, configuration-selected context, and deletion delegation, so this refactor does not expand that tool's authority.
Trust Boundaries and Controls
observed — Caller-supplied provider names still pass through GetProviderOperationLock validation before lock-file construction. MCP deletion and provider use retain operation-lock acquisition before their protected provider-state operations; the new helper does not bypass that control.
Resilience and Maintainability Implications
observed — Release errors remain discarded, as they were in the duplicated caller blocks. This is pre-existing failure handling, not a newly introduced loss of release-error visibility.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 11 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: introducing a shared provider operation lock helper and migrating callers to it.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Fix all pre-merge checks with AI
✨ Finishing Touches
✨ Simplify code
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
provider.LockProviderandprovider.LockProviderNamedinpkg/provider/operationlock.go. Each acquires the provider operation lock and returns an unlock func. Migrates 9 duplicatedGetProviderOperationLock -> Lock() -> defer Unlock()sites to them. Error strings are byte-identical.Why
Nine call sites repeated the same 9-line lock block with the same error wrapping. The
for <name>variant is kept only where it already existed (add.go,rename.go), viaLockProviderNamed.Skipped
pkg/workspace/provider_update.go: it returns the get-lock error bare, so migrating would add aget operation lock:prefix and change error text.Validation
mise run cli:format: no changesmise run cli:lint:ci: 0 issuesgo build ./...: okgo vetonpkg/provider,cmd/provider,cmd/pro,cmd/mcp,pkg/workspace: cleango test -count=1 ./pkg/provider/... ./cmd/provider/... ./cmd/pro/... ./cmd/mcp/... ./pkg/workspace/...: all okTestLockProvider*tests: passCodeRabbit CLI
coderabbit review --agent --committed --base-commit e0fe773ad: completed, 0 findings, 11 files reviewed.Auto-merge
Eligible: yes. Behaviour-preserving, no go.mod/go.sum, workflow, lint config, secret, or credential/auth changes, and no tests removed or weakened.
Summary by CodeRabbit