Skip to content

fix(openclaw): resolve environment variables in Viewer config API#1492

Open
xutao0565 wants to merge 4 commits intoMemTensor:dev-v2.0.14from
xutao0565:fix/issue-1490
Open

fix(openclaw): resolve environment variables in Viewer config API#1492
xutao0565 wants to merge 4 commits intoMemTensor:dev-v2.0.14from
xutao0565:fix/issue-1490

Conversation

@xutao0565
Copy link
Copy Markdown

Description

The Viewer's /api/config endpoint now recursively resolves environment variable references in openclaw.json configuration 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.ts
  • apps/memos-local-plugin/src/viewer/server.ts

Fixes #1490

Type of change

  • Bug fix (non-breaking change which fixes an issue)

pelagius and others added 4 commits April 17, 2026 10:47
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants