fix(schema): validate all schema files with draft2020 and strict mode#9594
fix(schema): validate all schema files with draft2020 and strict mode#9594
Conversation
- validate all schema/ files instead of a hardcoded subset - use draft2020 for all schemas (previously mixed draft-07, draft2019) - remove --strict-schema flag which doesn't exist in ajv; enable --strict-types and --strict-tuples instead - replace union type arrays with oneOf to satisfy AJV strictTypes
Greptile SummaryThis PR standardizes JSON Schema validation across all Confidence Score: 5/5Safe to merge; all changes are correctness improvements with no P0/P1 issues. Only P2 findings: one about the hk check validating only changed files rather than all schemas, and the pre-existing Element type inaccuracy in schema.ts. No logic errors, data loss, or security concerns. hk.pkl — verify whether the intent is to validate all schemas unconditionally or only changed ones per run. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["hk check triggered\n(schema/**/*.json changed)"] --> B["files_list piped via stdin\nas null-separated paths"]
B --> C["xargs -0 -I {}"]
C --> D["ajv compile -s {file}\n--spec=draft2020\n--strict-types=true\n--strict-tuples=true"]
D -->|pass| E{more files?}
D -->|fail| F["xargs exits non-zero\nCI fails"]
E -->|yes| D
E -->|no| G["All schemas valid ✓"]
H["xtasks/render/schema.ts"] --> I{props.type == BoolOrString?}
I -->|yes| J["Set type = __bool_or_string__\n(sentinel)"]
J --> K["delete element.type\nadd element.oneOf:\n[boolean, string]"]
I -->|no| L["Normal typeMap lookup\n(string / boolean / array / object)"]
K --> M["Write to schema/mise.json"]
L --> M
Reviews (2): Last reviewed commit: "chore: simplify with stdin and xargs" | Re-trigger Greptile |
There was a problem hiding this comment.
Code Review
This pull request updates several JSON schemas to the draft/2020-12 specification and replaces union type arrays with 'oneOf' constructs to comply with AJV strict type checking. It also modifies the schema validation task in 'hk.pkl' and the schema rendering script in 'xtasks/render/schema.ts' to support these changes. A review comment suggests removing unnecessary type casts in the TypeScript rendering script to improve code safety and readability.
### 🚀 Features - **(backend)** support top-level aqua cosign verification by @risu729 in [#9111](#9111) ### 🐛 Bug Fixes - **(schema)** validate all schema files with draft2020 and strict mode by @risu729 in [#9594](#9594) - **(shim)** skip network resolution for installed tool dirs by @jdx in [#9599](#9599) ### 📚 Documentation - **(dev-tools)** clarify vfox metadata depends for install hooks by @risu729 in [#9573](#9573) - **(plugins)** remove registry submission guidance by @risu729 in [#9577](#9577) ### 📦️ Dependency Updates - lock file maintenance by @renovate[bot] in [#9586](#9586) ### 📦 Registry - remove bashly asdf fallback by @risu729 in [#9578](#9578) - use github backend for rebar by @risu729 in [#9576](#9576) - add wasm-tools ([aqua:bytecodealliance/wasm-tools](https://github.com/bytecodealliance/wasm-tools)) by @2xdevv in [#9596](#9596) - enable symlink_bins for elixir-ls by @AlternateRT in [#9592](#9592) ### Chore - **(release)** always append sponsor block to release notes by @jdx in [#9580](#9580) - warn on vendored vfox embedded plugins by @risu729 in [#9588](#9588) - prefer registry shorthands over cargo/npm backends in mise.toml by @risu729 in [#9595](#9595) ## 📦 Aqua Registry Updates ### New Packages (2) - [`salesforce/reactive-grpc/protoc-gen-reactor-grpc`](https://github.com/salesforce/reactive-grpc) - [`spinframework/spin`](https://github.com/spinframework/spin) ### Updated Packages (1) - [`pnpm/pnpm`](https://github.com/pnpm/pnpm)
Summary
schema/files — previously only a hardcoded subset was validated; now the hk check iterates over allschema/**/*.jsonfilesmise-registry-tool.json,mise-settings.json) and draft2019 (mise.json,mise-task.json); now consistently usesdraft/2020-12--strict-schemaflag — this flag doesn't exist inajv compile(confirmed viaajv help compile); replaced with--strict-types=trueand--strict-tuples=trueoneOf— union type syntax like"type": ["string", "boolean"]triggers AJVstrictTypeserrors; replaced with explicitoneOfconstructs in both hand-written schemas and theschema.tsrenderer for generated schemas (BoolOrStringtype)