fix(openclaw): resolve environment variables in Viewer config API#1492
Open
xutao0565 wants to merge 4 commits intoMemTensor:dev-v2.0.14from
Open
fix(openclaw): resolve environment variables in Viewer config API#1492xutao0565 wants to merge 4 commits intoMemTensor:dev-v2.0.14from
xutao0565 wants to merge 4 commits intoMemTensor:dev-v2.0.14from
Conversation
Add module-level singleton guard (activeInstances Map) keyed by stateDir to detect and clean up previous instances when register() is called multiple times (deferred reload, gateway restart). Key changes: - Resolve stateDir early in register() to check for duplicates - Snapshot previous instance and defer cleanup to startServiceCore() - Gracefully stop previous viewer/hub/worker before binding new ports - Update ViewerServer.stop() to return Promise for proper port release - Add setTimeout guard to prevent stale instances from self-starting - Update test mocks to match async stop() signature
remoteHitMap entries accumulate when users search but never request detail. Add a 5-minute interval timer to sweep expired entries, following the same pattern as offlineCheckTimer. Clean up the timer in stop() to prevent leaks on shutdown.
Verifies that cleanExpiredRemoteHits correctly removes expired entries from the map, preventing memory leaks from unused search results.
The Viewer's /api/config endpoint now recursively resolves environment
variable references stored as { source: 'env', id: 'VAR_NAME' } in
openclaw.json, so API keys and other sensitive values don't need to be
hardcoded in the config file.
Fixes MemTensor#1490
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
26392aa to
a5f23b0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Viewer's
/api/configendpoint now recursively resolves environment variable references inopenclaw.jsonconfiguration files.Problem:
When users store API keys as environment variable references (e.g.,
{ "source": "env", "id": "MY_API_KEY" }), the Viewer would display the raw object instead of the actual value, causing connection errors.Solution:
Added
resolveEnvVars()method that recursively traverses the config object and replaces env references with actual environment variable values before returning to the frontend.Files Changed
apps/memos-local-openclaw/src/viewer/server.tsapps/memos-local-plugin/src/viewer/server.tsFixes #1490
Type of change