Skip to content

cliproxyapi fix - #1080

Merged
shunkakinoki merged 6 commits into
mainfrom
fix/cliproxyapi
Mar 13, 2026
Merged

cliproxyapi fix#1080
shunkakinoki merged 6 commits into
mainfrom
fix/cliproxyapi

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Mar 13, 2026

Copy link
Copy Markdown
Owner
  • feat: add additional package for agent integration in settings
  • feat: enhance cliproxyapi with common script for S3 operations and config management
  • feat: add spec file check for common.sh in cliproxyapi coverage

Summary by cubic

Unifies S3/objectstore handling for cliproxyapi with a shared common.sh, standardizes on a single auths/ S3 path with a configurable bucket, and simplifies service scripts. Also improves OpenClaw hydration (uses ~/.cli-proxy-api/config.yaml), adds cagdotin/agents to Pi, blocks unsafe Docker prune commands, and fixes container lifecycle to prevent 502s during switches.

  • New Features

    • Added scripts/common.sh (env loading, creds checks, S3 sync); injected into hydrate.sh, backup.sh, start.sh, and wrapper.sh via Nix.
    • Standardized to s3://$OBJECTSTORE_BUCKET/auths/ (default cliproxyapi); removed backup/auths; README/specs updated; supports bucket overrides.
    • OpenClaw gateway hydrate prefers API key from ~/.cli-proxy-api/config.yaml, then env, then secret file.
    • Added https://github.com/cagdotin/agents to Pi packages; expanded blocklist to include docker system prune -a/-f.
  • Bug Fixes

    • Prevent 502s on switches: stop Docker before remove to free the container name.
    • Harden usage export trap by guarding unset vars (${VAR:-}).
    • Makefile: reload systemd units instead of restarting; Home Manager handles restarts.

Written for commit 55d711f. Summary will update on new commits.

Copilot AI review requested due to automatic review settings March 13, 2026 22:28
@mesa-dot-dev

mesa-dot-dev Bot commented Mar 13, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ea54542-afc0-4769-8eab-c0cd37e672b5

📥 Commits

Reviewing files that changed from the base of the PR and between d9d6a96 and 55d711f.

📒 Files selected for processing (5)
  • Makefile
  • config/claude/settings.json
  • home-manager/services/cliproxyapi/default.nix
  • home-manager/services/cliproxyapi/scripts/common.sh
  • home-manager/services/cliproxyapi/scripts/start.sh

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced API key resolution with multiple fallback sources and environment-based prioritization
    • Docker-aware service startup flow for improved deployment flexibility
  • Bug Fixes

    • Added gateway token validation to prevent service hydration without required credentials
  • Chores

    • Simplified auth data synchronization by removing redundant backup storage paths
    • Added security restrictions for certain docker operations
    • Updated service reload behavior for cleaner configuration management
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'cliproxyapi fix' is vague and does not clearly convey the main changes in the pull request, which include S3 operations refactoring, API key resolution improvements, and new package additions. Revise the title to be more specific and descriptive, such as 'Refactor cliproxyapi S3 operations and improve API key resolution' to better reflect the main objectives.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly relates to the changeset, covering S3 operations unification, cliproxyapi improvements, API key resolution from config, and package additions.

✏️ 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 fix/cliproxyapi
📝 Coding Plan
  • Generate coding plan for human review comments

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, 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 significantly refines the cliproxyapi service by centralizing common shell script logic for S3 operations and credential management, leading to more robust and maintainable code. It also updates the openclaw configuration to intelligently resolve CLIPROXY_API_KEY from various sources and integrates a new agent package. These changes improve the reliability and flexibility of the cliproxyapi's interaction with S3 and its overall configuration.

Highlights

  • Centralized S3 Operations: A new shared shell script, common.sh, was introduced to centralize S3 operation logic and environment variable handling for cliproxyapi services, promoting code reuse and maintainability.
  • Refactored cliproxyapi Scripts: The backup.sh, hydrate.sh, start.sh, and wrapper.sh scripts for cliproxyapi were refactored to utilize the new common.sh for consistent S3 interactions and streamlined credential management.
  • Enhanced API Key Resolution: The openclaw hydration script (hydrate.sh) was updated to prioritize CLIPROXY_API_KEY retrieval from the cli-proxy-api/config.yaml file, providing a more flexible and configurable approach before falling back to environment variables or secret files.
  • Streamlined S3 Storage: The concept of a 'backup' S3 bucket for cliproxyapi authentication data was removed, simplifying S3 storage to a single primary location and updating related documentation and scripts.
  • New Agent Package Integration: A new package for agent integration (https://github.com/cagdotin/agents) was added to the pi/settings.json configuration.
  • Improved Test Coverage: Test coverage was enhanced by adding checks for the new common.sh script and updating existing tests to reflect the revised S3 logic and API key resolution, ensuring robustness of the changes.
Changelog
  • config/openclaw/hydrate.sh
    • Added CLIPROXY_CONFIG variable to specify the path for cli-proxy-api/config.yaml.
    • Implemented read_cliproxy_api_key_from_config function to extract API keys from the cliproxyapi config file.
    • Modified CLIPROXY_API_KEY resolution logic to prioritize reading from config.yaml before falling back to environment variables or secret files.
  • config/pi/settings.json
    • Added https://github.com/cagdotin/agents to the list of configured packages.
  • home-manager/services/cliproxyapi/README.md
    • Simplified the S3 storage description by removing the redundant backup path.
    • Updated the data flow diagram to reflect the single S3 auths path.
    • Revised hydrate and backup steps to remove references to the backup S3 path.
  • home-manager/services/cliproxyapi/default.nix
    • Introduced commonScript to encapsulate shared AWS CLI logic.
    • Updated hydrateScript, backupScript, startScript, and wrapperScript to use commonScript instead of directly embedding AWS CLI paths.
  • home-manager/services/cliproxyapi/scripts/backup.sh
    • Sourced the new common.sh script.
    • Replaced manual environment variable loading and credential stripping with cliproxy_init_objectstore_env.
    • Replaced manual S3 credential checks with cliproxy_has_objectstore_credentials.
    • Replaced direct aws s3 sync commands with cliproxy_sync_auth_to_s3, removing the backup S3 sync.
  • home-manager/services/cliproxyapi/scripts/common.sh
    • Added a new script containing shared shell functions: cliproxy_load_env, cliproxy_strip_quotes, cliproxy_init_objectstore_env, cliproxy_has_objectstore_credentials, cliproxy_auth_s3_uri, cliproxy_s3_sync, cliproxy_sync_auth_from_s3, cliproxy_sync_auth_to_s3.
  • home-manager/services/cliproxyapi/scripts/hydrate.sh
    • Sourced the new common.sh script.
    • Replaced manual environment variable loading and credential stripping with cliproxy_init_objectstore_env.
    • Replaced manual S3 credential checks with cliproxy_has_objectstore_credentials.
    • Replaced direct aws s3 sync commands with cliproxy_sync_auth_from_s3, removing the backup S3 sync.
  • home-manager/services/cliproxyapi/scripts/start.sh
    • Sourced the new common.sh script.
    • Replaced manual environment variable loading and credential stripping with cliproxy_init_objectstore_env.
    • Replaced manual S3 credential checks with cliproxy_has_objectstore_credentials.
    • Replaced direct aws s3 sync commands with cliproxy_sync_auth_from_s3 and cliproxy_sync_auth_to_s3, removing the backup S3 sync.
  • home-manager/services/cliproxyapi/scripts/wrapper.sh
    • Sourced the new common.sh script.
    • Replaced manual environment variable loading and credential stripping with cliproxy_init_objectstore_env.
    • Replaced manual S3 credential checks with cliproxy_has_objectstore_credentials.
    • Replaced direct aws s3 sync commands with cliproxy_sync_auth_from_s3 and cliproxy_sync_auth_to_s3, removing the backup S3 sync.
  • spec/cliproxyapi_backup_spec.sh
    • Added preprocessing for the new common.sh script.
    • Updated hydrate and backup tests to reflect the removal of the backup S3 path.
    • Added new tests to verify the use of OBJECTSTORE_BUCKET for S3 paths during hydrate and backup operations.
  • spec/coverage_spec.sh
    • Added a spec file check for home-manager/services/cliproxyapi/scripts/common.sh.
    • Included home-manager/services/cliproxyapi/scripts/common.sh in the list of files for coverage.
  • spec/openclaw_hydrate_spec.sh
    • Added a test to confirm CLIPROXY_CONFIG path usage.
    • Added new tests for gateway API key resolution, ensuring cliproxyapi config takes precedence over secret files.
Activity
  • No human activity has been recorded on this pull request yet.
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 Mar 13, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Unifies S3/objectstore handling for cliproxyapi via a shared common.sh, simplifies service scripts, and standardizes on a single auths/ S3 path with a configurable bucket. Also improves Kyber/OpenClaw hydration by reading the CLI Proxy API key from ~/.cli-proxy-api/config.yaml, adds the cagdotin/agents package to Pi settings, and blocks unsafe docker system prune commands in config/claude/settings.json.

What changed?

  • S3/Objectstore Handling & cliproxyapi service scripts:
    • Added home-manager/services/cliproxyapi/scripts/common.sh with utility bash functions for environment variable loading, credential checks, and S3 synchronization.
    • Refactored home-manager/services/cliproxyapi/default.nix to centralize variable replacement using the new commonScript for hydrateScript, backupScript, startScript, and wrapperScript.
    • home-manager/services/cliproxyapi/scripts/backup.sh and home-manager/services/cliproxyapi/scripts/hydrate.sh now utilize shared utility functions from common.sh for environment initialization, credential checking, and S3 synchronization.
    • home-manager/services/cliproxyapi/scripts/start.sh now injects @aws@ and @common@ for consistent S3 sync at boot.
    • home-manager/services/cliproxyapi/scripts/wrapper.sh likely updated for initialization, env setup, or execution command.
    • home-manager/services/cliproxyapi/README.md updated to reflect the single primary auths/ S3 path, removing references to an eliminated backup S3 bucket.
  • API Key Resolution:
    • config/openclaw/hydrate.sh: Prioritizes CLIPROXY_API_KEY resolution from ~/.cli-proxy-api/config.yaml, then environment variable, and finally a secret file.
  • Package and Settings Updates:
    • config/pi/settings.json: Added https://github.com/cagdotin/agents to the packages list.
    • config/claude/settings.json: Expanded the unsafe command blocklist to include docker system prune -a and docker system prune -f.
  • Testing and Coverage:
    • spec/cliproxyapi_backup_spec.sh: Incorporated common.sh and added new test cases for OBJECTSTORE_BUCKET environment variable usage and single-path sync validation.
    • spec/coverage_spec.sh: Extended code coverage tracking to home-manager/services/cliproxyapi/scripts/common.sh.
    • spec/openclaw_hydrate_spec.sh: Added new tests to verify .cli-proxy-api/config.yaml as the primary source for the API key and clarified the loading hierarchy.

Description generated by Mesa. Update settings

@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 several enhancements for cliproxyapi. It refactors S3 operations into a common shell script, simplifying the hydrate, backup, start, and wrapper scripts and removing duplicated code. It also removes the redundant S3 backup path, streamlining the data flow. Additionally, it enhances the openclaw/hydrate.sh script to read the CLIPROXY_API_KEY from the cliproxyapi configuration file, with appropriate fallbacks. The changes are well-tested, with updates to existing specs and new tests for the added functionality. My review includes a couple of suggestions to improve code conciseness and error reporting in the shell scripts.

Comment on lines +63 to +73
cliproxy_api_key_from_env="${CLIPROXY_API_KEY:-}"
CLIPROXY_API_KEY="${OPENCLAW_CLIPROXY_API_KEY:-}"
if [ -z "$CLIPROXY_API_KEY" ]; then
CLIPROXY_API_KEY="$(read_cliproxy_api_key_from_config "$CLIPROXY_CONFIG")"
fi
if [ -z "$CLIPROXY_API_KEY" ]; then
CLIPROXY_API_KEY="$cliproxy_api_key_from_env"
fi
if [ -z "$CLIPROXY_API_KEY" ]; then
CLIPROXY_API_KEY="$(read_secret "${SECRETS_DIR}/cliproxy-key")"
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

The chain of if statements to determine CLIPROXY_API_KEY is functionally correct, but a bit verbose. You can make this more concise by using && short-circuiting, which improves readability without changing the logic of conditional execution.

Suggested change
cliproxy_api_key_from_env="${CLIPROXY_API_KEY:-}"
CLIPROXY_API_KEY="${OPENCLAW_CLIPROXY_API_KEY:-}"
if [ -z "$CLIPROXY_API_KEY" ]; then
CLIPROXY_API_KEY="$(read_cliproxy_api_key_from_config "$CLIPROXY_CONFIG")"
fi
if [ -z "$CLIPROXY_API_KEY" ]; then
CLIPROXY_API_KEY="$cliproxy_api_key_from_env"
fi
if [ -z "$CLIPROXY_API_KEY" ]; then
CLIPROXY_API_KEY="$(read_secret "${SECRETS_DIR}/cliproxy-key")"
fi
cliproxy_api_key_from_env="${CLIPROXY_API_KEY:-}"
CLIPROXY_API_KEY="${OPENCLAW_CLIPROXY_API_KEY:-}"
[ -z "$CLIPROXY_API_KEY" ] && CLIPROXY_API_KEY="$(read_cliproxy_api_key_from_config "$CLIPROXY_CONFIG")"
[ -z "$CLIPROXY_API_KEY" ] && CLIPROXY_API_KEY="$cliproxy_api_key_from_env"
[ -z "$CLIPROXY_API_KEY" ] && CLIPROXY_API_KEY="$(read_secret "${SECRETS_DIR}/cliproxy-key")"

--endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \
--no-progress \
"$source_path" \
"$destination_path" || true

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

The || true at the end of the aws s3 sync command will cause any sync failures to be silently ignored. While this prevents the script from exiting due to set -e, it also hides potentially important errors. It would be better to log a warning message to stderr if the sync fails. This provides visibility into failures without halting the script.

Suggested change
"$destination_path" || true
"$destination_path" || echo "⚠️ S3 sync failed. Source: '$source_path', Destination: '$destination_path'" >&2

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 refactors the cliproxyapi service scripts to centralize S3/objectstore behavior into a shared common.sh, adjusts the docs/tests accordingly, and updates OpenClaw hydration to optionally resolve the Cliproxy API key from the cliproxyapi config.

Changes:

  • Introduces home-manager/services/cliproxyapi/scripts/common.sh and updates cliproxyapi scripts to source it for env loading and auth-cache S3 sync.
  • Updates tests/coverage specs and cliproxyapi README to reflect the new S3/auth flow and bucket override behavior.
  • Enhances config/openclaw/hydrate.sh to prefer the first api-keys entry from ~/.cli-proxy-api/config.yaml (gateway mode), with new ShellSpec coverage.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/openclaw_hydrate_spec.sh Adds assertions + an execution test for resolving Cliproxy API key from cliproxyapi config.
spec/coverage_spec.sh Adds common.sh to the required coverage list.
spec/cliproxyapi_backup_spec.sh Updates tests to preprocess/source common.sh and validates OBJECTSTORE_BUCKET usage.
home-manager/services/cliproxyapi/scripts/wrapper.sh Sources common.sh and delegates auth sync to shared helpers.
home-manager/services/cliproxyapi/scripts/start.sh Sources common.sh and delegates auth sync; still contains direct @aws@ syncs for config mirroring.
home-manager/services/cliproxyapi/scripts/hydrate.sh Sources common.sh and uses shared hydrate helper.
home-manager/services/cliproxyapi/scripts/common.sh New shared functions for env loading, credential checks, and S3 auth sync.
home-manager/services/cliproxyapi/scripts/backup.sh Sources common.sh and uses shared backup helper.
home-manager/services/cliproxyapi/default.nix Wires common.sh into other scripts via replaceVars.
home-manager/services/cliproxyapi/README.md Updates documentation to remove the redundant backup/auths/ path.
config/pi/settings.json Adds an additional package repository URL.
config/openclaw/hydrate.sh Adds config-based Cliproxy API key resolution in gateway mode.

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

You can also share your feedback on Copilot code review. Take the survey.

startScript = pkgs.replaceVars ./scripts/start.sh {
sed = "${pkgs.gnused}/bin/sed";
aws = "${pkgs.awscli2}/bin/aws";
common = commonScript;

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🧹 Nitpick comments (2)
config/openclaw/hydrate.sh (1)

34-49: The YAML parser makes assumptions about the config format.

The awk-based parser assumes api-keys are formatted as - "value" with double quotes. This works for the expected config format, but consider adding a fallback for unquoted values or values with single quotes if the config format may vary.

💡 Optional: Handle unquoted and single-quoted values
 read_cliproxy_api_key_from_config() {
   local config_file="$1"
   [ -f "$config_file" ] || return 0
 
   awk '
     /^api-keys:/ { in_api_keys = 1; next }
     in_api_keys && /^  - / {
       value = $0
-      sub(/^  - "/, "", value)
-      sub(/"$/, "", value)
+      sub(/^  - ["'\'']?/, "", value)
+      sub(/["'\'']?$/, "", value)
       print value
       exit
     }
     in_api_keys && /^[^[:space:]]/ { exit }
   ' "$config_file"
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/openclaw/hydrate.sh` around lines 34 - 49, The awk-based parser in
read_cliproxy_api_key_from_config assumes api-keys are indented as `  - "value"`
and only strips double quotes; update the function to accept unquoted values and
single-quoted values by loosening the pattern and trimming optional leading `- `
and optional surrounding single or double quotes before printing; specifically
change the awk block in read_cliproxy_api_key_from_config to capture the list
item regardless of quoting (or fallback to a simple strip of leading `  - ` then
remove leading/trailing quotes if present) so it returns values like value,
'value', and "value".
home-manager/services/cliproxyapi/README.md (1)

38-40: Add a language specifier to the fenced code block.

The code block is missing a language identifier. Since this is a simple text flow diagram, use text or plaintext as the language specifier to satisfy markdown linting.

📝 Proposed fix
-``` 
+```text
 S3 auths/ -> ~/.cli-proxy-api/objectstore/auths -> ~/.ccs/cliproxy/auth
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @home-manager/services/cliproxyapi/README.md around lines 38 - 40, The fenced
code block in README.md containing "S3 auths/ ->
~/.cli-proxy-api/objectstore/auths -> ~/.ccs/cliproxy/auth" lacks a language
specifier; update that triple-backtick block to include a language token such as
text or plaintext (e.g., ```text) so the markdown linter accepts it and the
snippet renders correctly.


</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against the current code and only fix it if needed.

Inline comments:
In @home-manager/services/cliproxyapi/scripts/common.sh:

  • Around line 38-48: The cliproxy_s3_sync helper currently swallows errors by
    appending "|| true"; remove that trailing "|| true" from the cliproxy_s3_sync
    function so the s3 sync command returns its real exit code, allowing failures to
    propagate; then update callers (e.g., start.sh and wrapper.sh) to rely on set
    -euo pipefail or to explicitly check the return code of cliproxy_s3_sync and
    implement retry/failure handling as needed.
  • Around line 12-17: The function cliproxy_strip_quotes currently only removes
    double quotes; update it to handle both single and double-quoted .env values by
    detecting and stripping matching leading and trailing quote characters (either '
    or ") from the input value (cliproxy_strip_quotes) before returning; ensure you
    only remove a pair of matching quotes (not internal or mismatched quotes) so
    cliproxy_init_objectstore_env() receives the unquoted credential/endpoint
    strings.

In @spec/openclaw_hydrate_spec.sh:

  • Line 130: The test command currently chains the hydrate invocation and cat
    with a semicolon so failures from the hydrate script are masked; update the
    shell invocation in spec/openclaw_hydrate_spec.sh (the line running bash -c
    'HOME="$TEMP_HOME" OPENCLAW_CONFIG_PATH="$TEMP_HOME/generated-openclaw.json"
    bash "$PREPROCESSED_SCRIPT" >/dev/null 2>&1; cat
    "$TEMP_HOME/generated-openclaw.json"') to use && between the hydrate invocation
    and the cat so the spec fails if the hydrate step (the bash
    "$PREPROCESSED_SCRIPT" call) exits non‑zero.

Nitpick comments:
In @config/openclaw/hydrate.sh:

  • Around line 34-49: The awk-based parser in read_cliproxy_api_key_from_config
    assumes api-keys are indented as - "value" and only strips double quotes;
    update the function to accept unquoted values and single-quoted values by
    loosening the pattern and trimming optional leading - and optional
    surrounding single or double quotes before printing; specifically change the awk
    block in read_cliproxy_api_key_from_config to capture the list item regardless
    of quoting (or fallback to a simple strip of leading - then remove
    leading/trailing quotes if present) so it returns values like value, 'value',
    and "value".

In @home-manager/services/cliproxyapi/README.md:

  • Around line 38-40: The fenced code block in README.md containing "S3 auths/ ->
    ~/.cli-proxy-api/objectstore/auths -> ~/.ccs/cliproxy/auth" lacks a language
    specifier; update that triple-backtick block to include a language token such as
    text or plaintext (e.g., ```text) so the markdown linter accepts it and the
    snippet renders correctly.

</details>

<details>
<summary>🪄 Autofix (Beta)</summary>

Fix all unresolved CodeRabbit comments on this PR:

- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: Organization UI

**Review profile**: CHILL

**Plan**: Pro

**Run ID**: `6a429a28-2fc8-44ea-b0a9-1c887d58b5b9`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 7241abbce182197257c967709a3406e78bf6f57f and d9d6a96f0cdc4b6bae495ccfb28b3c18ab5affb4.

</details>

<details>
<summary>📒 Files selected for processing (12)</summary>

* `config/openclaw/hydrate.sh`
* `config/pi/settings.json`
* `home-manager/services/cliproxyapi/README.md`
* `home-manager/services/cliproxyapi/default.nix`
* `home-manager/services/cliproxyapi/scripts/backup.sh`
* `home-manager/services/cliproxyapi/scripts/common.sh`
* `home-manager/services/cliproxyapi/scripts/hydrate.sh`
* `home-manager/services/cliproxyapi/scripts/start.sh`
* `home-manager/services/cliproxyapi/scripts/wrapper.sh`
* `spec/cliproxyapi_backup_spec.sh`
* `spec/coverage_spec.sh`
* `spec/openclaw_hydrate_spec.sh`

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines +12 to +17
cliproxy_strip_quotes() {
local value="$1"
value="${value%\"}"
value="${value#\"}"
printf '%s' "$value"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verifies current trimming behavior for double vs single quotes
v='"double-quoted"';  v="${v%\"}"; v="${v#\"}"; printf 'double => <%s>\n' "$v"
v="'single-quoted'";  v="${v%\"}"; v="${v#\"}"; printf 'single => <%s>\n' "$v"

Repository: shunkakinoki/dotfiles

Length of output: 118


🏁 Script executed:

cat -n home-manager/services/cliproxyapi/scripts/common.sh | sed -n '1,30p'

Repository: shunkakinoki/dotfiles

Length of output: 1155


🏁 Script executed:

rg "cliproxy_strip_quotes" -B 2 -A 10 home-manager/services/cliproxyapi/scripts/

Repository: shunkakinoki/dotfiles

Length of output: 2155


🏁 Script executed:

# Check for .env parsing context and how the function is called
rg "\.env|strip_quotes" home-manager/services/cliproxyapi/ -B 2 -A 2

Repository: shunkakinoki/dotfiles

Length of output: 2534


🏁 Script executed:

find home-manager/services/cliproxyapi -name "*.env*" -o -name "README*" | head -20

Repository: shunkakinoki/dotfiles

Length of output: 108


🏁 Script executed:

rg "\.env|quote" home-manager/services/cliproxyapi/README.md -B 1 -A 3

Repository: shunkakinoki/dotfiles

Length of output: 397


🏁 Script executed:

cat home-manager/services/cliproxyapi/README.md | grep -A 20 "Required in"

Repository: shunkakinoki/dotfiles

Length of output: 469


cliproxy_strip_quotes must handle both single and double-quoted .env values.

Lines 12-17 only strip double quotes ("). If .env contains single-quoted values like KEY='value', the quotes persist in the variable and break credential/endpoint usage in cliproxy_init_objectstore_env().

🔧 Suggested fix
 cliproxy_strip_quotes() {
   local value="$1"
-  value="${value%\"}"
-  value="${value#\"}"
+  case "$value" in
+    \"*\")
+      value="${value#\"}"
+      value="${value%\"}"
+      ;;
+    \'*\')
+      value="${value#\'}"
+      value="${value%\'}"
+      ;;
+  esac
   printf '%s' "$value"
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@home-manager/services/cliproxyapi/scripts/common.sh` around lines 12 - 17,
The function cliproxy_strip_quotes currently only removes double quotes; update
it to handle both single and double-quoted .env values by detecting and
stripping matching leading and trailing quote characters (either ' or ") from
the input value (cliproxy_strip_quotes) before returning; ensure you only remove
a pair of matching quotes (not internal or mismatched quotes) so
cliproxy_init_objectstore_env() receives the unquoted credential/endpoint
strings.

Comment on lines +38 to +48
cliproxy_s3_sync() {
local source_path="$1"
local destination_path="$2"
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY:?OBJECTSTORE_ACCESS_KEY is required}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY:?OBJECTSTORE_SECRET_KEY is required}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \
--no-progress \
"$source_path" \
"$destination_path" || true
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect where helper return semantics affect flow
rg -nP '\bcliproxy_s3_sync\b|\bcliproxy_sync_auth_(from|to)_s3\b' \
  home-manager/services/cliproxyapi/scripts/common.sh \
  home-manager/services/cliproxyapi/scripts/start.sh \
  home-manager/services/cliproxyapi/scripts/wrapper.sh

Repository: shunkakinoki/dotfiles

Length of output: 924


🏁 Script executed:

# Read the common.sh file to see the full context of the helper functions
head -70 home-manager/services/cliproxyapi/scripts/common.sh | tail -35

Repository: shunkakinoki/dotfiles

Length of output: 1120


🏁 Script executed:

# Read start.sh to see how these functions are called
cat home-manager/services/cliproxyapi/scripts/start.sh

Repository: shunkakinoki/dotfiles

Length of output: 5973


🏁 Script executed:

# Read wrapper.sh to see how these functions are called
cat home-manager/services/cliproxyapi/scripts/wrapper.sh

Repository: shunkakinoki/dotfiles

Length of output: 689


Remove || true from the helper function to propagate S3 sync failures to callers.

The || true on line 47 masks sync failures silently, preventing callers from detecting auth/config drift. Even though start.sh and wrapper.sh use set -euo pipefail, this cannot catch failures when the helper always returns 0. Neither caller checks the return value anyway, so failures are completely undetected. Move error handling to the caller level where decisions about retry or failure modes belong.

🔧 Suggested change
 cliproxy_s3_sync() {
   local source_path="$1"
   local destination_path="$2"
   AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY:?OBJECTSTORE_ACCESS_KEY is required}" \
     AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY:?OBJECTSTORE_SECRET_KEY is required}" \
     `@aws`@ s3 sync \
     --endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \
     --no-progress \
     "$source_path" \
-    "$destination_path" || true
+    "$destination_path"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cliproxy_s3_sync() {
local source_path="$1"
local destination_path="$2"
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY:?OBJECTSTORE_ACCESS_KEY is required}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY:?OBJECTSTORE_SECRET_KEY is required}" \
@aws@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \
--no-progress \
"$source_path" \
"$destination_path" || true
}
cliproxy_s3_sync() {
local source_path="$1"
local destination_path="$2"
AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY:?OBJECTSTORE_ACCESS_KEY is required}" \
AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY:?OBJECTSTORE_SECRET_KEY is required}" \
`@aws`@ s3 sync \
--endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \
--no-progress \
"$source_path" \
"$destination_path"
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@home-manager/services/cliproxyapi/scripts/common.sh` around lines 38 - 48,
The cliproxy_s3_sync helper currently swallows errors by appending "|| true";
remove that trailing "|| true" from the cliproxy_s3_sync function so the s3 sync
command returns its real exit code, allowing failures to propagate; then update
callers (e.g., start.sh and wrapper.sh) to rely on set -euo pipefail or to
explicitly check the return code of cliproxy_s3_sync and implement retry/failure
handling as needed.

After 'cleanup_gateway'

It 'prefers the root api-keys entry from cliproxyapi config over the secret file'
When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1; cat "'"$TEMP_HOME"'/generated-openclaw.json"'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Demonstrates status masking with ';' vs correct propagation with '&&'
bash -c 'false; true' >/dev/null 2>&1; echo "semicolon_chain_exit=$?"
bash -c 'false && true' >/dev/null 2>&1; echo "and_chain_exit=$?"

Repository: shunkakinoki/dotfiles

Length of output: 104


🏁 Script executed:

#!/bin/bash
# Check if the file exists and view context around line 130
if [ -f "spec/openclaw_hydrate_spec.sh" ]; then
    echo "File found. Viewing lines 125-135:"
    sed -n '125,135p' spec/openclaw_hydrate_spec.sh
else
    echo "File not found at spec/openclaw_hydrate_spec.sh"
    # Try to find it
    find . -name "*openclaw_hydrate*" -type f 2>/dev/null
fi

Repository: shunkakinoki/dotfiles

Length of output: 562


Use && instead of ; to ensure hydrate failures fail the spec.

At Line 130, the semicolon operator causes the exit status to be determined by cat regardless of whether the hydrate command failed. Use && to propagate failures from the bash script and properly fail the test when hydrate does not succeed.

Suggested change
-When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1; cat "'"$TEMP_HOME"'/generated-openclaw.json"'
+When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1 && cat "'"$TEMP_HOME"'/generated-openclaw.json"'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1; cat "'"$TEMP_HOME"'/generated-openclaw.json"'
When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1 && cat "'"$TEMP_HOME"'/generated-openclaw.json"'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@spec/openclaw_hydrate_spec.sh` at line 130, The test command currently chains
the hydrate invocation and cat with a semicolon so failures from the hydrate
script are masked; update the shell invocation in spec/openclaw_hydrate_spec.sh
(the line running bash -c 'HOME="$TEMP_HOME"
OPENCLAW_CONFIG_PATH="$TEMP_HOME/generated-openclaw.json" bash
"$PREPROCESSED_SCRIPT" >/dev/null 2>&1; cat
"$TEMP_HOME/generated-openclaw.json"') to use && between the hydrate invocation
and the cat so the spec fails if the hydrate step (the bash
"$PREPROCESSED_SCRIPT" call) exits non‑zero.

@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.

9 issues found across 12 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="spec/openclaw_hydrate_spec.sh">

<violation number="1" location="spec/openclaw_hydrate_spec.sh:130">
P2: Chain the hydrate step with `&&` so this spec actually fails when the gateway script exits non-zero.</violation>
</file>

<file name="home-manager/services/cliproxyapi/default.nix">

<violation number="1" location="home-manager/services/cliproxyapi/default.nix:17">
P1: `start.sh` still uses `@aws@`, but this replacement set no longer provides `aws`, so the generated startup script will break.</violation>
</file>

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

<violation number="1" location="home-manager/services/cliproxyapi/scripts/common.sh:29">
P2: Include `OBJECTSTORE_BUCKET` in the credentials check; otherwise an empty bucket passes the guard and crashes later during sync.</violation>

<violation number="2" location="home-manager/services/cliproxyapi/scripts/common.sh:47">
P1: Don't swallow S3 sync failures here; the backup/hydrate scripts currently treat failed transfers as success.</violation>
</file>

<file name="spec/cliproxyapi_backup_spec.sh">

<violation number="1" location="spec/cliproxyapi_backup_spec.sh:60">
P2: Clear `OBJECTSTORE_BUCKET` in test setup. Otherwise these new default-bucket assertions become host-dependent when the environment already exports a bucket name.</violation>
</file>

<file name="config/openclaw/hydrate.sh">

<violation number="1" location="config/openclaw/hydrate.sh:40">
P2: This parser only handles `api-keys` entries written exactly as `  - "..."`, so other valid YAML styles can produce a broken `apiKey` value.</violation>
</file>

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

<violation number="1" location="home-manager/services/cliproxyapi/scripts/wrapper.sh:16">
P2: This refactor stops writing auth files to the `backup/auths/` S3 path, so the secondary auth backup is no longer maintained.</violation>

<violation number="2" location="home-manager/services/cliproxyapi/scripts/wrapper.sh:18">
P1: This restore path no longer falls back to `backup/auths/`, so an empty or damaged primary `auths/` prefix leaves the CLI cache empty even when the backup copy still exists.</violation>
</file>

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

<violation number="1" location="home-manager/services/cliproxyapi/scripts/start.sh:13">
P2: Load the env-backed management URL after sourcing `.env`, otherwise `CLIPROXY_MANAGEMENT_URL` from `~/dotfiles/.env` is ignored.</violation>
</file>

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

};

hydrateScript = pkgs.replaceVars ./scripts/hydrate.sh {
common = commonScript;

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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: start.sh still uses @aws@, but this replacement set no longer provides aws, so the generated startup script will break.

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

<comment>`start.sh` still uses `@aws@`, but this replacement set no longer provides `aws`, so the generated startup script will break.</comment>

<file context>
@@ -9,17 +9,21 @@ let
   };
 
+  hydrateScript = pkgs.replaceVars ./scripts/hydrate.sh {
+    common = commonScript;
+  };
+
</file context>
Suggested change
common = commonScript;
aws = "${pkgs.awscli2}/bin/aws";
common = commonScript;
Fix with Cubic

--endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \
--no-progress \
"$source_path" \
"$destination_path" || true

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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: Don't swallow S3 sync failures here; the backup/hydrate scripts currently treat failed transfers as success.

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/common.sh, line 47:

<comment>Don't swallow S3 sync failures here; the backup/hydrate scripts currently treat failed transfers as success.</comment>

<file context>
@@ -0,0 +1,59 @@
+    --endpoint-url="${OBJECTSTORE_ENDPOINT:?OBJECTSTORE_ENDPOINT is required}" \
+    --no-progress \
+    "$source_path" \
+    "$destination_path" || true
+}
+
</file context>
Fix with Cubic

--no-progress \
"s3://${OBJECTSTORE_BUCKET}/backup/auths/" \
"$AUTH_DIR/" || true
cliproxy_sync_auth_from_s3 "$AUTH_DIR"

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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: This restore path no longer falls back to backup/auths/, so an empty or damaged primary auths/ prefix leaves the CLI cache empty even when the backup copy still exists.

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/wrapper.sh, line 18:

<comment>This restore path no longer falls back to `backup/auths/`, so an empty or damaged primary `auths/` prefix leaves the CLI cache empty even when the backup copy still exists.</comment>

<file context>
@@ -1,65 +1,21 @@
-      --no-progress \
-      "s3://${OBJECTSTORE_BUCKET}/backup/auths/" \
-      "$AUTH_DIR/" || true
+    cliproxy_sync_auth_from_s3 "$AUTH_DIR"
   fi
 fi
</file context>
Fix with Cubic

After 'cleanup_gateway'

It 'prefers the root api-keys entry from cliproxyapi config over the secret file'
When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1; cat "'"$TEMP_HOME"'/generated-openclaw.json"'

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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.

P2: Chain the hydrate step with && so this spec actually fails when the gateway script exits non-zero.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At spec/openclaw_hydrate_spec.sh, line 130:

<comment>Chain the hydrate step with `&&` so this spec actually fails when the gateway script exits non-zero.</comment>

<file context>
@@ -60,6 +70,70 @@ The output should include 'whatsapp-allow-from'
+After 'cleanup_gateway'
+
+It 'prefers the root api-keys entry from cliproxyapi config over the secret file'
+When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1; cat "'"$TEMP_HOME"'/generated-openclaw.json"'
+The status should be success
+The output should include 'from-cliproxy-config'
</file context>
Suggested change
When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1; cat "'"$TEMP_HOME"'/generated-openclaw.json"'
When run bash -c 'HOME="'"$TEMP_HOME"'" OPENCLAW_CONFIG_PATH="'"$TEMP_HOME"'/generated-openclaw.json" bash "'"$PREPROCESSED_SCRIPT"'" >/dev/null 2>&1 && cat "'"$TEMP_HOME"'/generated-openclaw.json"'
Fix with Cubic

Comment on lines +29 to +31
[ -n "${OBJECTSTORE_ENDPOINT:-}" ] &&
[ -n "${OBJECTSTORE_ACCESS_KEY:-}" ] &&
[ -n "${OBJECTSTORE_SECRET_KEY:-}" ]

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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.

P2: Include OBJECTSTORE_BUCKET in the credentials check; otherwise an empty bucket passes the guard and crashes later during sync.

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/common.sh, line 29:

<comment>Include `OBJECTSTORE_BUCKET` in the credentials check; otherwise an empty bucket passes the guard and crashes later during sync.</comment>

<file context>
@@ -0,0 +1,59 @@
+}
+
+cliproxy_has_objectstore_credentials() {
+  [ -n "${OBJECTSTORE_ENDPOINT:-}" ] &&
+    [ -n "${OBJECTSTORE_ACCESS_KEY:-}" ] &&
+    [ -n "${OBJECTSTORE_SECRET_KEY:-}" ]
</file context>
Suggested change
[ -n "${OBJECTSTORE_ENDPOINT:-}" ] &&
[ -n "${OBJECTSTORE_ACCESS_KEY:-}" ] &&
[ -n "${OBJECTSTORE_SECRET_KEY:-}" ]
[ -n "${OBJECTSTORE_ENDPOINT:-}" ] &&
[ -n "${OBJECTSTORE_BUCKET:-}" ] &&
[ -n "${OBJECTSTORE_ACCESS_KEY:-}" ] &&
[ -n "${OBJECTSTORE_SECRET_KEY:-}" ]
Fix with Cubic

@@ -6,18 +6,25 @@ SCRIPTS_DIR="$PWD/home-manager/services/cliproxyapi/scripts"

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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.

P2: Clear OBJECTSTORE_BUCKET in test setup. Otherwise these new default-bucket assertions become host-dependent when the environment already exports a bucket name.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At spec/cliproxyapi_backup_spec.sh, line 60:

<comment>Clear `OBJECTSTORE_BUCKET` in test setup. Otherwise these new default-bucket assertions become host-dependent when the environment already exports a bucket name.</comment>

<file context>
@@ -50,11 +57,22 @@ cleanup() {
 After 'cleanup'
 
-It 'pulls from S3 auths and backup/auths'
+It 'pulls from the configured S3 auth path'
 When run bash -c 'HOME="'"$TEMP_HOME"'" bash "'"$__HYDRATE_SCRIPT"'" 2>&1; cat "$MOCK_LOG" 2>/dev/null || true'
 The status should be success
</file context>
Fix with Cubic


awk '
/^api-keys:/ { in_api_keys = 1; next }
in_api_keys && /^ - / {

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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.

P2: This parser only handles api-keys entries written exactly as - "...", so other valid YAML styles can produce a broken apiKey value.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/openclaw/hydrate.sh, line 40:

<comment>This parser only handles `api-keys` entries written exactly as `  - "..."`, so other valid YAML styles can produce a broken `apiKey` value.</comment>

<file context>
@@ -30,6 +31,23 @@ read_secret() {
+
+  awk '
+    /^api-keys:/ { in_api_keys = 1; next }
+    in_api_keys && /^  - / {
+      value = $0
+      sub(/^  - "/, "", value)
</file context>
Fix with Cubic

--no-progress \
"$AUTH_DIR/" \
"s3://${OBJECTSTORE_BUCKET}/backup/auths/" || true
cliproxy_sync_auth_to_s3 "$AUTH_DIR"

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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.

P2: This refactor stops writing auth files to the backup/auths/ S3 path, so the secondary auth backup is no longer maintained.

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/wrapper.sh, line 16:

<comment>This refactor stops writing auth files to the `backup/auths/` S3 path, so the secondary auth backup is no longer maintained.</comment>

<file context>
@@ -1,65 +1,21 @@
-      --no-progress \
-      "$AUTH_DIR/" \
-      "s3://${OBJECTSTORE_BUCKET}/backup/auths/" || true
+    cliproxy_sync_auth_to_s3 "$AUTH_DIR"
   else
-    AWS_ACCESS_KEY_ID="$OBJECTSTORE_ACCESS_KEY" \
</file context>
Suggested change
cliproxy_sync_auth_to_s3 "$AUTH_DIR"
cliproxy_sync_auth_to_s3 "$AUTH_DIR"
cliproxy_s3_sync "$AUTH_DIR/" "s3://${OBJECTSTORE_BUCKET}/backup/auths/"
Fix with Cubic

OBJECTSTORE_BUCKET="$(strip_quotes "${OBJECTSTORE_BUCKET:-cliproxyapi}")"
OBJECTSTORE_ACCESS_KEY="$(strip_quotes "${OBJECTSTORE_ACCESS_KEY:-}")"
OBJECTSTORE_SECRET_KEY="$(strip_quotes "${OBJECTSTORE_SECRET_KEY:-}")"
cliproxy_init_objectstore_env

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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.

P2: Load the env-backed management URL after sourcing .env, otherwise CLIPROXY_MANAGEMENT_URL from ~/dotfiles/.env is ignored.

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 13:

<comment>Load the env-backed management URL after sourcing `.env`, otherwise `CLIPROXY_MANAGEMENT_URL` from `~/dotfiles/.env` is ignored.</comment>

<file context>
@@ -1,74 +1,31 @@
-OBJECTSTORE_BUCKET="$(strip_quotes "${OBJECTSTORE_BUCKET:-cliproxyapi}")"
-OBJECTSTORE_ACCESS_KEY="$(strip_quotes "${OBJECTSTORE_ACCESS_KEY:-}")"
-OBJECTSTORE_SECRET_KEY="$(strip_quotes "${OBJECTSTORE_SECRET_KEY:-}")"
+cliproxy_init_objectstore_env
 OBJECTSTORE_LOCAL_PATH="$CONFIG_DIR"
 MANAGEMENT_PASSWORD="${CLIPROXY_MANAGEMENT_PASSWORD:-}"
</file context>
Suggested change
cliproxy_init_objectstore_env
cliproxy_init_objectstore_env
MANAGEMENT_URL="${CLIPROXY_MANAGEMENT_URL:-http://127.0.0.1:8317/v0/management}"
Fix with Cubic

@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.

1 issue found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="config/claude/settings.json">

<violation number="1" location="config/claude/settings.json:333">
P1: These deny rules are bypassable with Docker's long-form flags (`--all`/`--force`), so equivalent destructive prune commands remain allowed.</violation>
</file>

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

Comment on lines +333 to +334
"Bash(docker system prune -a:*)",
"Bash(docker system prune -f:*)",

@cubic-dev-ai cubic-dev-ai Bot Mar 13, 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: These deny rules are bypassable with Docker's long-form flags (--all/--force), so equivalent destructive prune commands remain allowed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/claude/settings.json, line 333:

<comment>These deny rules are bypassable with Docker's long-form flags (`--all`/`--force`), so equivalent destructive prune commands remain allowed.</comment>

<file context>
@@ -330,6 +330,8 @@
       "Bash(rm -rf /*:*)",
       "Bash(rm -rf ~/*:*)",
       "Bash(chmod -R 777:*)",
+      "Bash(docker system prune -a:*)",
+      "Bash(docker system prune -f:*)",
       "Bash(mkfs:*)",
</file context>
Suggested change
"Bash(docker system prune -a:*)",
"Bash(docker system prune -f:*)",
"Bash(docker system prune -a:*)",
"Bash(docker system prune --all:*)",
"Bash(docker system prune -f:*)",
"Bash(docker system prune --force:*)",
Fix with Cubic

- Use docker stop before rm to fully free container name before reuse
- Guard usage_export trap against unbound variables with ${VAR:-}
- Remove redundant systemctl restart (home-manager handles it)
@shunkakinoki
shunkakinoki merged commit 471912d into main Mar 13, 2026
22 of 23 checks passed
@shunkakinoki
shunkakinoki deleted the fix/cliproxyapi branch March 13, 2026 23:07
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