Skip to content

feat(cliproxyapi): add auth backup recovery from dotfiles - #482

Merged
shunkakinoki merged 1 commit into
mainfrom
feat/cliproxyapi-auth-backup-recovery
Jan 1, 2026
Merged

feat(cliproxyapi): add auth backup recovery from dotfiles#482
shunkakinoki merged 1 commit into
mainfrom
feat/cliproxyapi-auth-backup-recovery

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Jan 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add rsync dependency to cliproxyapi service for file recovery operations
  • Implement automatic recovery of missing authentication files from git-tracked dotfiles backup
  • Recovery only runs on macOS since Linux Docker containers rely on R2 storage
  • Uses --ignore-existing flag to avoid overwriting newer files from other sources
  • Helps prevent authentication issues after system resets or clean setups

Changes

  • cliproxyapi service: Added rsync to available binaries
  • backup-auth.sh: Added recovery step from dotfiles backup after R2 and CCS sync
  • start.sh: Added bootstrap recovery during service initialization

Technical Details

The recovery mechanism checks for missing auth files in the git-tracked dotfiles directory (~/dotfiles/objectstore/auths) and restores them using rsync with --ignore-existing to preserve any newer files from R2 or CCS directories. This provides an additional layer of resilience for authentication file management.


Summary by cubic

Add automatic recovery of missing auth files from a git-tracked dotfiles backup on macOS to prevent auth errors after resets. Includes rsync in the cliproxyapi service and bootstraps recovery in start.sh and backup-auth.sh using --ignore-existing to avoid overwriting newer files.

Written for commit 37c9851. Summary will update on new commits.

- Add rsync to cliproxyapi service dependencies
- Implement recovery of missing auth files from git-tracked dotfiles backup
- Only runs on macOS since Linux Docker containers rely on R2 storage
- Uses --ignore-existing to avoid overwriting newer files
- Helps prevent authentication issues after system resets or clean setups
Copilot AI review requested due to automatic review settings January 1, 2026 14:16
@coderabbitai

coderabbitai Bot commented Jan 1, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved authentication file recovery on macOS by automatically restoring missing files from dotfiles backup before syncing to cloud storage.
  • Chores

    • Updated build configuration to properly resolve rsync dependencies in authentication management scripts.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

These changes add rsync path substitution to the cliproxyapi Nix configuration and introduce macOS-specific recovery logic to both the start and backup-auth scripts. The recovery mechanism rsyncs missing auth files from a dotfiles backup directory into the local AUTH_DIR before syncing, using --ignore-existing to preserve existing files.

Changes

Cohort / File(s) Summary
Rsync path substitution
home-manager/services/cliproxyapi/default.nix
Added pkgs.rsync path substitution to both startScript and backupAuthScript replaceVars invocations, enabling template use of ${pkgs.rsync}/bin/rsync in scripts.
macOS dotfiles recovery logic
home-manager/services/cliproxyapi/scripts/backup-auth.sh, scripts/start.sh
Introduced DOTFILES_AUTH_DIR variable and Darwin-only conditional recovery step in both scripts. Each performs rsync with --ignore-existing to recover missing auth files from dotfiles backup before proceeding with standard sync operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Hopping through dotfiles with rsync so bright,
On Darwin machines, auth files take flight,
Bootstrap recovery, a safety-net leap,
Missing auth files from backup we'll sweep! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(cliproxyapi): add auth backup recovery from dotfiles' clearly and concisely summarizes the main change: adding authentication file recovery functionality from a dotfiles backup to the cliproxyapi service.
Description check ✅ Passed The description provides comprehensive details about the changes, including the summary, specific modifications to files, and technical rationale for the implementation with context about macOS-specific behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/cliproxyapi-auth-backup-recovery

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5058ce9 and 37c9851.

📒 Files selected for processing (3)
  • home-manager/services/cliproxyapi/default.nix
  • home-manager/services/cliproxyapi/scripts/backup-auth.sh
  • home-manager/services/cliproxyapi/scripts/start.sh
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{sh,bash}

📄 CodeRabbit inference engine (CLAUDE.md)

Use shfmt with 2-space indentation for shell scripts

**/*.{sh,bash}: Use 2 spaces for indentation in shell scripts
Add proper shebang lines to shell scripts
Follow shellcheck recommendations in shell scripts
Document complex commands in shell scripts
Use consistent variable naming in shell scripts

Files:

  • home-manager/services/cliproxyapi/scripts/backup-auth.sh
  • home-manager/services/cliproxyapi/scripts/start.sh
**/*.nix

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.nix: Use nixfmt for formatting all Nix files
Document complex configurations with comments in Nix files

**/*.nix: Use 2 spaces for indentation in Nix files
Keep line length under 100 characters in Nix files
Sort attribute sets alphabetically in Nix files
Use consistent spacing around operators in Nix files
Format lists and sets consistently in Nix files

Use treefmt.toml for formatting Nix files

**/*.nix: Use mkOption for configurable options in Nix modules
Implement proper typing for all options in Nix modules
Follow the Nix expression language style guide

Files:

  • home-manager/services/cliproxyapi/default.nix
**/default.nix

📄 CodeRabbit inference engine (CLAUDE.md)

Use default.nix files for module exports

Files:

  • home-manager/services/cliproxyapi/default.nix
home-manager/services/*/default.nix

📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)

Service configurations should be located in home-manager/services/<name>/ with proper service definitions and correct dependency handling

Files:

  • home-manager/services/cliproxyapi/default.nix
home-manager/services/**/default.nix

📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)

Service configurations must include proper service definitions, handle dependencies correctly, and document service parameters

Files:

  • home-manager/services/cliproxyapi/default.nix
home-manager/**/*.nix

📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)

home-manager/**/*.nix: Use typed options whenever possible in Nix configurations
Document all configuration options in Nix modules and programs
Follow home-manager's module structure and keep configurations modular
Use proper indentation and formatting in Nix configuration files

Files:

  • home-manager/services/cliproxyapi/default.nix
home-manager/services/**/*.nix

📄 CodeRabbit inference engine (.cursor/rules/nix.mdc)

Service configurations in home-manager/services/ should follow systemd service conventions, include proper service dependencies, and have clear documentation for service parameters

Files:

  • home-manager/services/cliproxyapi/default.nix
🧠 Learnings (6)
📚 Learning: 2025-11-25T09:34:40.062Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/general.mdc:0-0
Timestamp: 2025-11-25T09:34:40.062Z
Learning: Document all major changes in Nix configurations

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/programs/**/*.nix : Follow program-specific best practices in program configuration files

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/services/**/default.nix : Service configurations must include proper service definitions, handle dependencies correctly, and document service parameters

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/**/*.nix : Document all configuration options in Nix modules and programs

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/**/*.nix : Follow home-manager's module structure and keep configurations modular

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
📚 Learning: 2025-11-25T09:34:55.014Z
Learnt from: CR
Repo: shunkakinoki/dotfiles PR: 0
File: .cursor/rules/home-manager.mdc:0-0
Timestamp: 2025-11-25T09:34:55.014Z
Learning: Applies to home-manager/programs/**/default.nix : Program configurations must include all necessary dependencies in their configuration

Applied to files:

  • home-manager/services/cliproxyapi/default.nix
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: Agent
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: nix-linux
  • GitHub Check: nix-nixos
  • GitHub Check: shell-lint
  • GitHub Check: shell-test
  • GitHub Check: docker-build-push (linux/amd64, amd64, ubuntu-latest)
  • GitHub Check: docker-build-push (linux/arm64, arm64, ubuntu-24.04-arm)
  • GitHub Check: e2e-run (NixOS, ubuntu-latest)
  • GitHub Check: e2e-run (Ubuntu, ubuntu-latest)
  • GitHub Check: lua-hammerspoon
  • GitHub Check: lua-neovim-test
  • GitHub Check: lua-neovim
🔇 Additional comments (5)
home-manager/services/cliproxyapi/default.nix (1)

11-11: LGTM: rsync path substitution added correctly.

The rsync path substitution is properly integrated into the startScript replaceVars call, consistent with the existing pattern for aws and sed. The rsync package is already available in the service PATH (lines 100 and 140), ensuring the substituted path will work at runtime.

home-manager/services/cliproxyapi/scripts/start.sh (2)

9-9: LGTM: dotfiles auth directory declared.

The DOTFILES_AUTH_DIR variable is consistently defined to match the git-tracked dotfiles backup location. The hardcoded path is appropriately guarded by existence checks in the recovery logic.


53-57: LGTM: macOS recovery logic is well-structured.

The recovery implementation correctly:

  • Gates execution to macOS (Darwin) only
  • Validates directory existence and content before attempting rsync
  • Uses --ignore-existing to preserve newer files from R2/CCS
  • Runs at the correct point in the bootstrap sequence (after R2 pull, before local-to-R2 push)

The approach aligns with the PR objectives to restore missing auth files after system resets without overwriting files that may be newer in R2 or CCS directories.

home-manager/services/cliproxyapi/scripts/backup-auth.sh (2)

12-12: LGTM: dotfiles auth directory consistently defined.

The DOTFILES_AUTH_DIR variable matches the definition in start.sh, ensuring consistent behavior across both scripts.


41-45: LGTM: recovery step properly integrated into sync flow.

The recovery logic is correctly positioned as STEP 3, running after:

  1. R2 pull (captures files created directly in R2)
  2. CCS sync (captures files created by ccs's internal cliproxy)

And before the final sync to R2. This ordering ensures the dotfiles backup serves as a fallback source without overwriting potentially newer files from R2 or CCS. The implementation is consistent with the start.sh recovery logic.


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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust authentication file recovery system for the cliproxyapi service, primarily targeting macOS users. It leverages git-tracked dotfiles as a backup source to automatically restore missing authentication files, thereby enhancing system resilience and preventing common authentication issues that can arise after system resets or new setups. The recovery process is designed to be non-destructive, prioritizing newer files from other sources.

Highlights

  • rsync Dependency: The rsync utility has been added as a dependency to the cliproxyapi service, making it available for file recovery operations within its scripts.
  • Dotfiles Auth Recovery: An automatic recovery mechanism has been implemented to restore missing authentication files by pulling them from a git-tracked dotfiles backup.
  • macOS Specific Recovery: This recovery process is specifically enabled for macOS systems, as Linux Docker containers are designed to rely on R2 storage for authentication files.
  • Non-destructive Recovery: The recovery uses the --ignore-existing flag with rsync to ensure that any newer authentication files already present from other sources (like R2 or CCS) are not inadvertently overwritten.
  • Bootstrap Recovery: A bootstrap recovery step has been integrated into the service initialization (start.sh) to ensure authentication files are present from the dotfiles backup when the service starts.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mesa-dot-dev

mesa-dot-dev Bot commented Jan 1, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Added automatic recovery of missing authentication files for the cliproxyapi service on macOS from git-tracked dotfiles, using rsync with --ignore-existing to prevent overwriting newer files and enhance resilience against authentication issues.

What changed?

  • cliproxyapi service: Added rsync to available binaries.
  • backup-auth.sh: Added a recovery step from dotfiles backup after R2 and CCS sync.
  • start.sh: Added bootstrap recovery during service initialization.

Description generated by Mesa. Update settings

@mesa-dot-dev mesa-dot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Performed full review of 5058ce9...37c9851

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

0 files reviewed | 0 comments | Edit Agent SettingsRead Docs

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a recovery mechanism for authentication files from a local dotfiles backup on macOS, which is a good addition for resilience. The implementation adds rsync as a dependency and incorporates the recovery logic into the service start and backup scripts. My review focuses on improving the maintainability and robustness of the new shell script logic. I've pointed out some duplicated code and suggested a more reliable way to check for non-empty directories.

Comment on lines +42 to +45
if [ "$(uname)" = "Darwin" ] && [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(ls -A "$DOTFILES_AUTH_DIR" 2>/dev/null)" ]; then
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Recovered missing auths from dotfiles backup (macOS)" >&2
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This logic block is very similar to the one in start.sh (lines 54-57). To avoid code duplication and improve maintainability, consider extracting this logic into a common helper script. The main difference is the success message, which could be passed as an argument or handled by the calling script.

Additionally, using ls to check if a directory is empty is not fully robust, as it can misbehave with certain filenames. A more reliable method is to use find.

Suggested change
if [ "$(uname)" = "Darwin" ] && [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(ls -A "$DOTFILES_AUTH_DIR" 2>/dev/null)" ]; then
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Recovered missing auths from dotfiles backup (macOS)" >&2
fi
if [ "$(uname)" = "Darwin" ] && [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(find "$DOTFILES_AUTH_DIR" -mindepth 1 -maxdepth 1 -print -quit)" ]; then
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Recovered missing auths from dotfiles backup (macOS)" >&2
fi

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +53 to +56
# Recover missing files from git-tracked dotfiles backup (macOS only; Linux Docker uses R2)
if [ "$(uname)" = "Darwin" ] && [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(ls -A "$DOTFILES_AUTH_DIR" 2>/dev/null)" ]; then
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Run dotfiles recovery even without objectstore creds

Because the dotfiles recovery block is nested inside the if [ -n "${OBJECTSTORE_ENDPOINT:-}" ] && [ -n "${OBJECTSTORE_ACCESS_KEY:-}" ] check, it never runs on macOS when objectstore credentials are unset. That defeats the new “recover from dotfiles backup” path for clean/local-only setups (exactly when you’d want it), leaving AUTH_DIR empty and causing downstream auth lookups to fail until another sync runs. Consider moving the dotfiles recovery outside the objectstore gate or relaxing the condition so it can seed auth files even when R2 creds are missing.

Useful? React with 👍 / 👎.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 3 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="home-manager/services/cliproxyapi/scripts/start.sh">

<violation number="1" location="home-manager/services/cliproxyapi/scripts/start.sh:54">
P1: The dotfiles recovery logic is nested inside the objectstore credentials conditional block. This means recovery from dotfiles backup will never run on macOS when `OBJECTSTORE_ENDPOINT` or `OBJECTSTORE_ACCESS_KEY` are unset - precisely the clean/local-only setup scenario where this fallback recovery is most needed. Consider moving this block outside the objectstore credentials gate so it can bootstrap auth files even when R2 credentials are missing.</violation>

<violation number="2" location="home-manager/services/cliproxyapi/scripts/start.sh:55">
P1: Missing error handling for rsync command. Under `set -euo pipefail`, if rsync fails (permission issues, disk full, etc.), the entire startup script will exit and the service won&#39;t start. This should follow the same pattern as the aws s3 sync commands with `|| true` to gracefully continue on failure.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

"$AUTH_DIR/" 2>/dev/null && echo "✅ Pulled from R2 backup/auths/" >&2 || true

# Recover missing files from git-tracked dotfiles backup (macOS only; Linux Docker uses R2)
if [ "$(uname)" = "Darwin" ] && [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(ls -A "$DOTFILES_AUTH_DIR" 2>/dev/null)" ]; then

@cubic-dev-ai cubic-dev-ai Bot Jan 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: The dotfiles recovery logic is nested inside the objectstore credentials conditional block. This means recovery from dotfiles backup will never run on macOS when OBJECTSTORE_ENDPOINT or OBJECTSTORE_ACCESS_KEY are unset - precisely the clean/local-only setup scenario where this fallback recovery is most needed. Consider moving this block outside the objectstore credentials gate so it can bootstrap auth files even when R2 credentials are missing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/services/cliproxyapi/scripts/start.sh, line 54:

<comment>The dotfiles recovery logic is nested inside the objectstore credentials conditional block. This means recovery from dotfiles backup will never run on macOS when `OBJECTSTORE_ENDPOINT` or `OBJECTSTORE_ACCESS_KEY` are unset - precisely the clean/local-only setup scenario where this fallback recovery is most needed. Consider moving this block outside the objectstore credentials gate so it can bootstrap auth files even when R2 credentials are missing.</comment>

<file context>
@@ -49,6 +50,12 @@ if [ -n &quot;${OBJECTSTORE_ENDPOINT:-}&quot; ] &amp;&amp; [ -n &quot;${OBJECTSTORE_ACCESS_KEY:-}&quot; ]; t
     &quot;$AUTH_DIR/&quot; 2&gt;/dev/null &amp;&amp; echo &quot;✅ Pulled from R2 backup/auths/&quot; &gt;&amp;2 || true
 
+  # Recover missing files from git-tracked dotfiles backup (macOS only; Linux Docker uses R2)
+  if [ &quot;$(uname)&quot; = &quot;Darwin&quot; ] &amp;&amp; [ -d &quot;$DOTFILES_AUTH_DIR&quot; ] &amp;&amp; [ -n &quot;$(ls -A &quot;$DOTFILES_AUTH_DIR&quot; 2&gt;/dev/null)&quot; ]; then
+    @rsync@ -a --ignore-existing &quot;$DOTFILES_AUTH_DIR/&quot; &quot;$AUTH_DIR/&quot;
+    echo &quot;✅ Bootstrapped auth files from dotfiles backup (macOS)&quot; &gt;&amp;2
</file context>
Fix with Cubic

Comment on lines +55 to +56
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2

@cubic-dev-ai cubic-dev-ai Bot Jan 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1: Missing error handling for rsync command. Under set -euo pipefail, if rsync fails (permission issues, disk full, etc.), the entire startup script will exit and the service won't start. This should follow the same pattern as the aws s3 sync commands with || true to gracefully continue on failure.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/services/cliproxyapi/scripts/start.sh, line 55:

<comment>Missing error handling for rsync command. Under `set -euo pipefail`, if rsync fails (permission issues, disk full, etc.), the entire startup script will exit and the service won&#39;t start. This should follow the same pattern as the aws s3 sync commands with `|| true` to gracefully continue on failure.</comment>

<file context>
@@ -49,6 +50,12 @@ if [ -n &quot;${OBJECTSTORE_ENDPOINT:-}&quot; ] &amp;&amp; [ -n &quot;${OBJECTSTORE_ACCESS_KEY:-}&quot; ]; t
 
+  # Recover missing files from git-tracked dotfiles backup (macOS only; Linux Docker uses R2)
+  if [ &quot;$(uname)&quot; = &quot;Darwin&quot; ] &amp;&amp; [ -d &quot;$DOTFILES_AUTH_DIR&quot; ] &amp;&amp; [ -n &quot;$(ls -A &quot;$DOTFILES_AUTH_DIR&quot; 2&gt;/dev/null)&quot; ]; then
+    @rsync@ -a --ignore-existing &quot;$DOTFILES_AUTH_DIR/&quot; &quot;$AUTH_DIR/&quot;
+    echo &quot;✅ Bootstrapped auth files from dotfiles backup (macOS)&quot; &gt;&amp;2
+  fi
</file context>
Suggested change
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" && echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2 || true
Fix with Cubic

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds automatic recovery of authentication files from a git-tracked dotfiles backup directory, providing an additional layer of resilience for authentication file management during system resets or clean setups.

  • Adds rsync as a dependency for file recovery operations
  • Implements automatic recovery from ~/dotfiles/objectstore/auths during service startup and backup
  • Recovery is macOS-only since Linux Docker containers rely on R2 storage

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
home-manager/services/cliproxyapi/default.nix Added rsync binary path substitution for start.sh script
home-manager/services/cliproxyapi/scripts/start.sh Added bootstrap recovery from dotfiles backup during service initialization
home-manager/services/cliproxyapi/scripts/backup-auth.sh Added recovery step from dotfiles backup after R2 and CCS sync operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

echo "✅ Synced from ccs auth dir to local cache" >&2
fi

# STEP 3: Recover missing files from git-tracked dotfiles backup (macOS only; Linux relies on R2)

Copilot AI Jan 1, 2026

Copy link

Choose a reason for hiding this comment

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

The comment labels the recovery step as "STEP 3" but the subsequent sync operations (lines 47-77) are not labeled as "STEP 4". For consistency with the existing step numbering scheme (STEP 1 and STEP 2), consider adding a "# STEP 4:" comment before line 47 or removing the step numbering from the new STEP 3 comment.

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +58
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2
fi

Copilot AI Jan 1, 2026

Copy link

Choose a reason for hiding this comment

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

The rsync command lacks error handling, which could cause the script to exit due to set -euo pipefail at line 5. If rsync fails for any reason (permissions, I/O errors, etc.), the entire startup process will fail. Consider adding error handling similar to the R2 operations, for example: @rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" && echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2 || echo "⚠️ Failed to bootstrap from dotfiles backup" >&2 || true

Suggested change
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2
fi
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" && echo "✅ Bootstrapped auth files from dotfiles backup (macOS)" >&2 || echo "⚠️ Failed to bootstrap from dotfiles backup" >&2 || true
fi

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +44
@rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/"
echo "✅ Recovered missing auths from dotfiles backup (macOS)" >&2

Copilot AI Jan 1, 2026

Copy link

Choose a reason for hiding this comment

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

The rsync command lacks error handling, which could cause the script to exit due to set -euo pipefail at line 5. If rsync fails for any reason (permissions, I/O errors, etc.), the backup process will fail. Consider adding error handling similar to the R2 operations, for example: @rsync@ -a --ignore-existing "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" && echo "✅ Recovered missing auths from dotfiles backup (macOS)" >&2 || echo "⚠️ Failed to recover from dotfiles backup" >&2 || true

Copilot uses AI. Check for mistakes.
@shunkakinoki
shunkakinoki merged commit ea83d90 into main Jan 1, 2026
35 checks passed
@shunkakinoki
shunkakinoki deleted the feat/cliproxyapi-auth-backup-recovery branch January 1, 2026 14:25
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.

2 participants