Skip to content

fix: 本地viewer不会解析配置文件的环境变量 #1490

Closed

Description

@xutao0565

Pre-submission checklist | 提交前检查

  • I have searched existing issues and this hasn't been mentioned before | 我已搜索现有问题,确认此问题尚未被提及
  • I have read the project documentation and confirmed this issue doesn't already exist | 我已阅读项目文档并确认此问题尚未存在
  • This issue is specific to MemOS and not a general software issue | 该问题是针对 MemOS 的,而不是一般软件问题

Bug Description | 问题描述

本地插件viewer直接从配置文件读取配置,不会解析环境变量,导致Embedding等模型的key必须硬编码在配置文件中

How to Reproduce | 如何重现

以openclaw为例,openclaw.json文件Embedding 模型的key替换成变量,Viewer界面连接报错

Environment | 环境信息

  • Operating System : macos V26.4.1
  • Memos Version: memos-local-openclaw-plugin v1.0.9-beta.2

Additional Context | 其他信息

No response

Willingness to Implement | 实现意愿

  • I'm willing to implement this myself | 我愿意自己解决
  • I would like someone else to implement this | 我希望其他人来解决

Activity

  1. changed the title [-]fix: 本地viewer不会解析配置文件[/-] [+]fix: 本地viewer不会解析配置文件的环境变量[/+] on Apr 17, 2026
  2. added 2 commits that reference this issue on Apr 17, 2026
    26392aa
    a5f23b0
  3. MaiHHConnect commented on Apr 19, 2026

    @MaiHHConnect
  4. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 29, 2026
  5. Memtensor-AI commented on Jun 30, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: 750b19581f7f5526
    Working branch: bugfix/autodev-1490
    Target branch: latest dev* branch
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  6. self-assigned this
    on Jun 30, 2026
  7. added a commit that references this issue on Jun 30, 2026
    5386365
  8. Memtensor-AI commented on Jun 30, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 750b19581f7f5526 completed.

    Summary: Fixes #1490: the local viewer in apps/memos-local-openclaw was reading openclaw.json directly in three paths (handleTestModel, serveFallbackModel, runMigration) without expanding ${VAR} env-var literals. Users who stored secrets in their config as "apiKey": "${MY_API_KEY}" saw 401s because the literal placeholder ended up in the Bearer header. resolveConfig() already had a deepResolveEnv() helper, but it was private and only applied to the in-memory plugin context.

    The fix exports deepResolveEnv / resolveEnvVars from src/config.ts, adds readPluginConfigResolved / readOpenClawResolvedConfig helpers in ViewerServer, and routes every "about-to-call-the-network" string (apiKey/endpoint/baseUrl in the migration summarizer, fallback model probe, and embedding/chat test endpoints) through the resolver. serveConfig is intentionally left raw so the UI can still display ${VAR} literals for editing — secrets never round-trip back into the file.

    Test plan: added tests/viewer-env-resolution.test.ts (4 cases) covering test-model env expansion, fallback-model env expansion, the new resolved-config helper, and the raw-passthrough property of serveConfig. All 4 pass. Full vitest suite: 226 pass / 5 fail, where the 5 failures (accuracy, skill-auto-install, task-processor, update-install) reproduce identically on unmodified dev-20260615-v2.0.20 (confirmed via git stash baseline) and depend on the local huggingface embedding cache / fake-timer process.kill timing — unrelated to this change. tsc build passes clean.

    Base branch: main
    Branch: bugfix/autodev-1490
    Commit: 5386365
    PR: #1984
    Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller
    Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219, @World-controller

  9. added
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 30, 2026
  10. added a commit that references this issue on Jul 1, 2026
    1feefe1
  11. added and removed
    ai:pr-readyAI-created PR is ready for review | AI 生成的 PR 已等待评审
    on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:pluginOpenClaw & Hermestypes:bugSomething isn't working | 功能异常

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions