Skip to content

Fix updater cleanup for stale OpenClaw install metadata#186

Open
0xCheetah1 wants to merge 4 commits into
BlockRunAI:mainfrom
0xCheetah1:fix/stale-install-metadata-cleanup
Open

Fix updater cleanup for stale OpenClaw install metadata#186
0xCheetah1 wants to merge 4 commits into
BlockRunAI:mainfrom
0xCheetah1:fix/stale-install-metadata-cleanup

Conversation

@0xCheetah1

@0xCheetah1 0xCheetah1 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • clean stale ClawRouter records from OpenClaw's legacy plugin install index after a successful update
  • compare legacy metadata against the current ClawRouter package across old and project-scoped npm install layouts
  • leave unrelated legacy plugin metadata untouched

Testing

  • bash -n scripts/update.sh
  • validated on testbed: stale legacy ClawRouter metadata was removed and subsequent openclaw doctor archived the legacy install index without the conflicting metadata warning

Summary by CodeRabbit

  • Bug Fixes
    • Improved the plugin update process with automatic cleanup of stale legacy install metadata to keep local install records consistent with the current installed state.
    • Reaffirmed fixes for safer handling of non-ASCII routing reasoning in proxy debug headers after payment settlement.
    • Reaffirmed upstream proxy fallback behavior (including NO_PROXY/loopback handling) when BLOCKRUN_UPSTREAM_PROXY is unset.
  • Tests
    • Strengthened header sanitization and debug-header parsing test assertions for clarity and robustness.
  • Documentation
    • Refreshed formatting/alignment of “Environment Variables” tables in the main README and configuration docs (content unchanged).

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7472f7df-1be7-4674-82d9-02890fc25897

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0374d and ea88523.

📒 Files selected for processing (1)
  • src/proxy.reasoning-header.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/proxy.reasoning-header.test.ts

📝 Walkthrough

Walkthrough

scripts/update.sh gains a post-cleanup step that runs an inline Node.js snippet to locate and clean stale ClawRouter entries in OpenClaw's legacy plugin install index (~/.openclaw/plugins/installs.json). It scans candidate directories for the current package, compares versions and paths, and atomically rewrites the JSON with outdated records removed. The PR also includes release notes entries confirming proxy fallback and header encoding features, and applies formatting consistency to configuration documentation and proxy-related test code.

Changes

ClawRouter Metadata Cleanup with Supporting Documentation and Formatting

Layer / File(s) Summary
Stale metadata detection and removal
scripts/update.sh
New cleanup step reads ~/.openclaw/plugins/installs.json, identifies the newest ClawRouter package.json by mtime across several candidate directories, and if the legacy installRecords entry has a mismatched path or version, deletes the clawrouter install record and matching plugin array items, updates refreshReason and generatedAtMs, and writes the file back atomically. Exits without modification if the index is absent, no package is found, or the record already matches; any error logs a "Skipped" message.
Release notes and configuration documentation
CHANGELOG.md, README.md, docs/configuration.md
CHANGELOG entries affirm v0.12.208 fix for non-ASCII routing reasoning header crashes via percent-encoding and v0.12.207 support for HTTPS_PROXY/HTTP_PROXY/ALL_PROXY fallback with undici proxy agent. README and docs/configuration environment variable tables are reformatted for alignment consistency while preserving all variable names, defaults, and descriptions.
Proxy and reasoning header code formatting
src/upstream-proxy.ts, src/proxy.reasoning-header.test.ts, test/upstream-proxy.test.ts
Proxy fallback environment variable selection in applyEnvProxyFallback is reformatted to multiline argument list; reasoning header test precondition check is updated from regex to code-point assertion and test callback is reformatted to multiline style; upstream proxy test assertions are wrapped across multiple lines. No functional logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Fix updater cleanup for stale OpenClaw install metadata' directly describes the main change: adding a post-update cleanup step to remove stale ClawRouter records from OpenClaw's install metadata.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/update.sh`:
- Around line 936-945: The newestCurrentPackage() function currently selects the
package candidate with the most recent modification time (mtimeMs), which can
incorrectly choose a stale project-scoped or npm-layout copy if it was touched
more recently than the active extension install. Change the selection logic to
prioritize the active extension install location
(~/.openclaw/extensions/clawrouter) first before falling back to other
candidates. Modify the comparison that updates the best variable to check if the
candidate is the verified active install and prefer it, only using mtimeMs as a
secondary comparison when choosing between non-active candidates or candidates
in the same category.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a0a948ba-016d-48f3-b45d-500bfd284fd1

📥 Commits

Reviewing files that changed from the base of the PR and between ea680b0 and d8bdce0.

📒 Files selected for processing (1)
  • scripts/update.sh

Comment thread scripts/update.sh

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

🧹 Nitpick comments (1)
src/proxy.reasoning-header.test.ts (1)

54-56: 💤 Low value

Consider reverting to the simpler regex approach.

The new Array.from(reasoning).some((ch) => (ch.codePointAt(0) ?? 0) > 0x7f) check is functionally equivalent to the previous regex /[^\x00-\x7F]/ but significantly more verbose. For this test's purpose—verifying that the reasoning string contains at least one non-ASCII character—the regex is clearer and more idiomatic. The ?? 0 fallback is also unnecessary since codePointAt(0) on a character from Array.from always returns a number.

♻️ Simpler approach
-    expect(
-      Array.from(reasoning).some((ch) => (ch.codePointAt(0) ?? 0) > 0x7f),
-    ).toBe(true);
+    expect(reasoning).toMatch(/[^\x00-\x7F]/);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/proxy.reasoning-header.test.ts` around lines 54 - 56, Replace the verbose
Array.from(reasoning).some((ch) => (ch.codePointAt(0) ?? 0) > 0x7f) check in the
expect statement with a simpler regex approach. Use the regex pattern
/[^\x00-\x7F]/ to test if the reasoning string contains at least one non-ASCII
character by calling test() on the regex against the reasoning variable, which
is clearer and more idiomatic for this purpose.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/proxy.reasoning-header.test.ts`:
- Around line 54-56: Replace the verbose Array.from(reasoning).some((ch) =>
(ch.codePointAt(0) ?? 0) > 0x7f) check in the expect statement with a simpler
regex approach. Use the regex pattern /[^\x00-\x7F]/ to test if the reasoning
string contains at least one non-ASCII character by calling test() on the regex
against the reasoning variable, which is clearer and more idiomatic for this
purpose.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: da536eed-59cf-41d2-82ab-1894e73b80af

📥 Commits

Reviewing files that changed from the base of the PR and between 09c65bf and 9f0374d.

📒 Files selected for processing (2)
  • scripts/update.sh
  • src/proxy.reasoning-header.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/update.sh

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.

1 participant