Skip to content

feat: strict zod schema validation for openclaw.json top-level keys #6

Description

@cncoder

背景

schema 使用混合:

  • `src/config/zod-schema.agent-runtime.ts:419` 用了 `.strict()`
  • `src/config/zod-schema.hooks.ts:96` 用了 `.passthrough()`
  • `src/config/zod-schema.providers.ts:46` 用了 `.passthrough()`(允许 extension channel)

`.passthrough()` 让拼写错误的 key 静默被吞:`channels.discrod` vs `channels.discord` 配置看似生效实则无效。

提案

  • 顶层 `openclaw.json` schema 用 `.strict()`,拼写错误启动时报错
  • 需要开放扩展的点(providers / custom channels)明确用 `.catchall(z.unknown())` 而不是 passthrough,并在文档标注
  • 启动时 unknown key 打印 WARN 列表(让用户看得见)

收益

早期暴露配置错误,避免"配了没生效"类 issue。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions