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
pkg/provider/dir.go: the six Get*Dir guards call requireID. The Save and Load functions use the helpers. SaveWorkspaceResult keeps its existence check and does not create the directory.
pkg/provider/export.go: the three tar+base64 blocks share archiveDirBase64.
pkg/provider/persist_test.go: table-driven tests for the helpers.
Why
Each Save and Load function repeated the same marshal, write, and unmarshal steps. Consolidating them reduces the duplicated code paths that must stay consistent.
Preserved behavior: per-type file modes (0o600 and 0o644), the ... is empty and workspace ... no longer exists error texts, the no-MkdirAll path for workspace results, and the Origin and Context fields set on load.
Validation
go build ./...
go vet ./pkg/provider/
mise run cli:format
mise run cli:lint:ci (0 issues)
go test ./pkg/provider/... ./pkg/workspace/... ./pkg/options/... (pass)
CodeRabbit CLI
coderabbit review --agent --committed --base-commit 56102eb completed with 0 findings across 4 files.
Auto-merge
Eligible: yes. Behavior-preserving refactor, 4 files, about 205 insertions and 146 deletions. No tests weakened, no restricted paths, and no lint disabled or //nolint added.
Summary by CodeRabbit
Bug Fixes
Invalid identifiers are now rejected consistently when accessing provider, machine, and workspace directories.
Configuration and workspace result files now report read and write errors more consistently, including missing or invalid files.
Workspace result saving still requires an existing workspace configuration and does not create a missing workspace directory.
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: 1ede854a-12d7-4913-8269-34fdeee29993
📥 Commits
Reviewing files that changed from the base of the PR and between 56102eb and 7d14af1.
📒 Files selected for processing: 4
pkg/provider/dir.go
pkg/provider/export.go
pkg/provider/persist.go
pkg/provider/persist_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 directory validation, JSON persistence, and directory archive creation now use shared helpers. Persistence tests cover identifier checks, JSON operations, file permissions, and error cases.
Config save and load functions use shared JSON helpers. Save modes remain 0600 for provider, Pro instance, and machine configs, and 0644 for workspace configs. Workspace result saving still requires an existing workspace config. Tests cover JSON round trips, permissions, absent parent directories, missing files, and invalid JSON.
Directory archive creation pkg/provider/export.go
Workspace, machine, and provider exports use archiveDirBase64. The helper applies the existing exclusions, encodes archives as raw base64, and labels compression errors by directory kind.
This is a behavior-preserving refactor of provider persistence and export helpers, with new tests for the helpers. No concrete merge-blocking risk was found.
Security architecture risk:⚪ Minimal · up to 7d14a
The refactor preserves existing file permissions, workspace-existence checks, atomic-write behavior, and export filtering. No material security risk was found to be introduced or worsened, and no security findings remain.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The changed paths retain the same filesystem targets and export sources for provider, machine, Pro instance, and workspace state. The helper extraction does not introduce additional callers, credentials, privileges, or cross-service access.
Trust Boundaries and Controls
observed — Operation-specific permissions remain explicit at callers: provider, Pro instance, machine, and workspace-result files use 0600; workspace configuration uses 0644. Directory creation retains 0755. The shared helpers do not choose a broader permission policy.
Resilience and Maintainability Implications
observed — The unchanged atomic writer retains same-directory temporary files, pre-rename cleanup attempts, permission setting, synchronization, and atomic replacement. Concurrent writers remain last-rename-wins, and directory synchronization may fail after replacement. The workspace existence check is still separate from the write. These are pre-existing failure and concurrency semantics, not new guarantees or regressions introduced by the helpers.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 27.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 29 functions across 4 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: consolidating provider configuration persistence logic into shared helpers.
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
Share the save, load, and id-guard logic in
pkg/provider/dir.gothrough private helpers. Public signatures and behavior are unchanged.pkg/provider/persist.go:requireID,saveJSON,writeJSONFile,loadJSON[T].pkg/provider/dir.go: the sixGet*Dirguards callrequireID. The Save and Load functions use the helpers.SaveWorkspaceResultkeeps its existence check and does not create the directory.pkg/provider/export.go: the three tar+base64 blocks sharearchiveDirBase64.pkg/provider/persist_test.go: table-driven tests for the helpers.Why
Each Save and Load function repeated the same marshal, write, and unmarshal steps. Consolidating them reduces the duplicated code paths that must stay consistent.
Preserved behavior: per-type file modes (0o600 and 0o644), the
... is emptyandworkspace ... no longer existserror texts, the no-MkdirAll path for workspace results, and theOriginandContextfields set on load.Validation
go build ./...go vet ./pkg/provider/mise run cli:formatmise run cli:lint:ci(0 issues)go test ./pkg/provider/... ./pkg/workspace/... ./pkg/options/...(pass)CodeRabbit CLI
coderabbit review --agent --committed --base-commit 56102ebcompleted with 0 findings across 4 files.Auto-merge
Eligible: yes. Behavior-preserving refactor, 4 files, about 205 insertions and 146 deletions. No tests weakened, no restricted paths, and no lint disabled or
//nolintadded.Summary by CodeRabbit