refactor(config): drop unused safeParse wrappers and stale Zod comments in config/schema.ts
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 62/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- cli
调研方向
Start by running rg for the five unused exports (ApiKeyAuthSchema, BasicAuthSchema, AuthSchema, ServiceBlockSchema, ConfigFileSchema) in src/config/schema.ts to confirm only tests use them, then run rg -i zod src to find the stale comments in loader.ts, ajv-validate.ts, json-schema-args.ts, namespaces.ts and factory.ts. Done means the wrappers and their tests are removed with a justification, the post-checks live only in ContextSchema, rg -i zod src is empty, and npm test and npx tsc --noEmit pass. Leave the strip* helpers and additionalProperties alone, since #716 covers them.
由索引模型根据 Issue 内容生成。
描述
Summary
src/config/schema.ts exports five ajv-backed safeParse wrappers that nothing in src/ calls. Only tests use them. Several comments across src/ also still describe validation as Zod-based, but zod has been removed from the project.
Unused exports (current main):
ApiKeyAuthSchema(line 306)BasicAuthSchema(line 316)AuthSchema(line 326)ServiceBlockSchema(line 335)ConfigFileSchema(line 402)
Production code uses only StructuralConfigSchema (loader.ts, completion/complete.ts, completers/context-names.ts), ContextSchema (loader.ts, config/commands.ts) and CommandPolicySchema (loader.ts, completion/complete.ts).
ConfigFileSchema also duplicates the three per-context post-checks from ContextSchema, with different wording:
- At least one service block:
ContextSchemaline 382-383 vsConfigFileSchemaline 426-427 ("at least one service block required"). contextUrlErrors: line 385 vs line 429.contextVersionErrors: line 387 vs line 431.
These were around lines 378-385 and 431-440 in an earlier revision.
Stale Zod comments:
src/config/loader.ts:14: "Validate active context with full Zod schemas"src/lib/ajv-validate.ts:7src/lib/json-schema-args.ts:9src/namespaces.ts:107src/factory.ts:737
Proposal
- Delete the five unused wrappers and their tests. Deleting
ConfigFileSchemaremoves the duplicated post-checks, soContextSchemabecomes their single home. - Update the Zod comments so they describe the current ajv/JSON Schema behaviour.
The PR must explicitly justify deleting the tests for the removed wrappers: they cover only code being removed, and the behaviour that remains is still covered through ContextSchema/StructuralConfigSchema.
Out of scope: deferred to #716 (design decision 1)
This issue does not cover replacing the strip* helpers (schema.ts ~238-298, plus the ! assertions on their results) with ValidateFunction<T> type guards, or adding additionalProperties: false. Either change would alter behaviour. Today unknown config keys are silently stripped (schema.ts:137: "no additionalProperties — we strip manually"). A type guard would pass them through, and additionalProperties: false would reject them, which would break existing configs that have extra keys. Both options also overlap with #716's raw-shape plus per-field leaf validator split, which reshapes ContextSchema, contextUrlErrors, contextVersionErrors and the strip* helpers. Decide them there.
Acceptance criteria
-
ConfigFileSchema,AuthSchema,ApiKeyAuthSchema,BasicAuthSchemaandServiceBlockSchemaare removed, or any that stay have a documented reason. - The three per-context post-checks exist only in
ContextSchema. - No comment in
src/refers to Zod (rg -i zod srcis empty). - The PR justifies each deleted test.
- No behaviour change: unknown keys are still stripped, and
npm testandnpx tsc --noEmitpass.
Related
- #716 (design decision 1: the
strip*/type-guard and unknown-key handling is deferred there)
authored by Pi Coding Agent (Claude Opus)
- 主要语言
- TypeScript
- 星标
- 51
- 派生
- 27
- 平均合并
- 22 小时 48 分钟
- 30 天内合并 PR
- 48
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
elastic/cli 的其他 Issue
-
tracking
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
feat: ship skills/elastic/SKILL.md for agent invocation可能已有人在做 @onatozmenn 于 28 天前认领。 未关闭enhancement
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
tracking
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
Deduplicate lazy stub-leaf and stub-swap logic in es/kb register可能已有人在做 @JoshMock 于 9 天前认领。 未关闭Stale
难度 4/5 3-5 天 新手友好度 30/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
Merit-Systems/x402scan#1312 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Native Web
难度 1/5 1 小时以内 新手友好度 80/100
digitalfabrik/integreat-app#4517 ·
维护者通常 2 天内回复
-
TLS guide repeats certs/ in the certificate directory可能已有人在做 @maheshrijal 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
prometheus/docs#3156 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
medusajs/dtc-starter#90 ·
维护者通常 1 天内回复