Skip to content

fix: save profile to global path#4697

Merged
avallete merged 2 commits intodevelopfrom
global-prof
Mar 9, 2026
Merged

fix: save profile to global path#4697
avallete merged 2 commits intodevelopfrom
global-prof

Conversation

@sweatybridge
Copy link
Contributor

@sweatybridge sweatybridge commented Jan 7, 2026

What kind of change does this PR introduce?

Bug fix

What is the new behavior?

Since profile is loaded before changing workdir, we can't rely on project specific temp directory.

Instead, we use the user home directory for caching the current profile.

Additional context

Add any other context or screenshots.

@sweatybridge sweatybridge requested a review from a team as a code owner January 7, 2026 15:56
@coveralls
Copy link

Pull Request Test Coverage Report for Build 20787465907

Details

  • 1 of 18 (5.56%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.09%) to 55.948%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/login.go 0 1 0.0%
internal/utils/profile.go 1 17 5.88%
Files with Coverage Reduction New Missed Lines %
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 20786687458: -0.09%
Covered Lines: 6848
Relevant Lines: 12240

💛 - Coveralls

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Improved internal profile path handling with enhanced directory resolution logic. Profile persistence mechanism updated to use dynamic path computation instead of static path definitions, with better error handling for home directory access.

Walkthrough

The changes refactor profile name persistence in the login command by replacing a hard-coded constant path with dynamic resolution based the user's HOME directory. The exported ProfilePath variable is removed from path definitions. A new exported function SaveProfileName() is introduced to handle profile persistence, backed by an internal helper getProfilePath() that computes the profile file path dynamically. The login command's PostRunE is updated to call the new SaveProfileName() function instead of directly writing to the constant path. Error handling is enhanced to account for HOME directory resolution failures.


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.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/utils/profile.go`:
- Around line 146-152: SaveProfileName currently writes prof verbatim which lets
relative custom profile paths break when reloaded; update SaveProfileName so
that if the value is a non-built-in profile (i.e., will be treated as a file
path by LoadProfile) you canonicalize it before persisting by calling
filepath.Clean and converting to an absolute path (use filepath.Abs) when prof
is not already absolute, then write that canonical path with WriteFile; keep
behavior for built-in names unchanged and preserve error handling from
getProfilePath.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f0613fac-7e97-4c56-892b-986e156b87c7

📥 Commits

Reviewing files that changed from the base of the PR and between ba32edc and d18bf38.

📒 Files selected for processing (3)
  • cmd/login.go
  • internal/utils/misc.go
  • internal/utils/profile.go
💤 Files with no reviewable changes (1)
  • internal/utils/misc.go

@avallete avallete merged commit b4918f3 into develop Mar 9, 2026
22 of 23 checks passed
@avallete avallete deleted the global-prof branch March 9, 2026 15:12
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.

3 participants