From 9eb3d2e7d480608739f6e5c8dbc1cf75e0bb4243 Mon Sep 17 00:00:00 2001 From: Alexander Petric Date: Thu, 12 Nov 2026 01:14:10 -0500 Subject: [PATCH] fix(cli): point wmill.yaml schema header at an absolute, release-pinned URL (#12367) `wmill init` wrote `# yaml-language-server: $schema=wmill.schema.json`, a path relative to the user's wmill.yaml where no schema file exists, so the YAML language server loaded nothing. The header now names cli/wmill.schema.json at the CLI's own release tag on raw.githubusercontent.com. The committed schema had drifted since v1.834.0 (it lacked includeDatatablePermissions); regenerate it and add a unit test that fails while it is stale. Co-authored-by: Claude Opus 5.5 --- cli/src/commands/init/template.ts | 13 +++++++++++-- cli/test/init_template_unit.test.ts | 19 +++++++++++++++++-- cli/wmill.schema.json | 4 ++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/cli/src/commands/init/template.ts b/cli/src/commands/init/template.ts index 6b5f220bff..b8f4887681 100644 --- a/cli/src/commands/init/template.ts +++ b/cli/src/commands/init/template.ts @@ -1,3 +1,5 @@ +import { VERSION } from "../../core/constants.ts"; + /** * Configuration option descriptor — each entry IS a JSON Schema property * with extra metadata for template rendering and reference table display. @@ -10,7 +12,8 @@ * Adding a new option: * 1. Add an entry to CONFIG_REFERENCE with JSON Schema type fields + description * 2. Add template rendering hints (section, commented, templateValue, etc.) - * 3. `wmill init` (YAML template), `wmill config` (table), and wmill.schema.json all update automatically + * 3. `wmill init` (YAML template) and `wmill config` (table) update automatically + * 4. Regenerate wmill.schema.json: `bun generate-schema.ts` */ export interface ConfigOption { // --- JSON Schema fields (kept when generating schema) --- @@ -259,10 +262,16 @@ function yamlKey(s: string): string { return `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`; } +// Absolute and pinned to this CLI's release tag: nothing copies the schema next +// to the user's wmill.yaml (nor into the npm package), and the tag's schema lists +// exactly the options this CLI version accepts. +export const WMILL_SCHEMA_URL = + `https://raw.githubusercontent.com/windmill-labs/windmill/v${VERSION}/cli/wmill.schema.json`; + export function generateCommentedTemplate(branchName?: string, binding?: BranchBinding, bindings?: WorkspaceBinding[]): string { const branch = yamlKey(branchName ?? "main"); const lines: string[] = [ - "# yaml-language-server: $schema=wmill.schema.json", + `# yaml-language-server: $schema=${WMILL_SCHEMA_URL}`, "# wmill.yaml — Windmill CLI configuration", '# Full reference: run "wmill config"', "", diff --git a/cli/test/init_template_unit.test.ts b/cli/test/init_template_unit.test.ts index 7070de63c8..391d31d7fe 100644 --- a/cli/test/init_template_unit.test.ts +++ b/cli/test/init_template_unit.test.ts @@ -3,8 +3,11 @@ */ import { expect, test, describe } from "bun:test"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; import { parse } from "yaml"; import Ajv from "ajv"; +import { VERSION } from "../src/core/constants.ts"; import { generateCommentedTemplate, generateJsonSchema, @@ -65,9 +68,13 @@ describe("generateCommentedTemplate", () => { expect(config.workspaces["prod"].workspaceId).toBe("prod-ws"); }); - test("contains yaml-language-server schema directive", () => { + // The header must be an absolute URL: a relative path resolves next to the + // user's wmill.yaml, where no schema file exists. + test("first line points the YAML language server at the schema of this CLI's release tag", () => { const yaml = generateCommentedTemplate("main"); - expect(yaml.startsWith("# yaml-language-server: $schema=wmill.schema.json")).toBe(true); + expect(yaml.split("\n")[0]).toBe( + `# yaml-language-server: $schema=https://raw.githubusercontent.com/windmill-labs/windmill/v${VERSION}/cli/wmill.schema.json`, + ); }); test("includes all non-commented, non-skipped CONFIG_REFERENCE entries as active YAML keys", () => { @@ -105,6 +112,14 @@ describe("generateCommentedTemplate", () => { describe("generateJsonSchema", () => { const schema = generateJsonSchema(); + // wmill.yaml headers fetch cli/wmill.schema.json from the release tag, so the + // committed file is what users validate against. Regenerate: `bun generate-schema.ts`. + test("matches the committed cli/wmill.schema.json", () => { + const committed = readFileSync(join(import.meta.dir, "..", "wmill.schema.json"), "utf-8") + .replace(/\r\n/g, "\n"); + expect(committed).toBe(JSON.stringify(schema, null, 2) + "\n"); + }); + test("is a valid JSON Schema draft-07", () => { expect(schema.$schema).toBe("http://json-schema.org/draft-07/schema#"); expect(schema.type).toBe("object"); diff --git a/cli/wmill.schema.json b/cli/wmill.schema.json index 15af745438..2b9c047c42 100644 --- a/cli/wmill.schema.json +++ b/cli/wmill.schema.json @@ -93,6 +93,10 @@ "type": "boolean", "description": "Include workspace settings in sync" }, + "includeDatatablePermissions": { + "type": "boolean", + "description": "With includeSettings, also sync each data table's roles and who may connect as them" + }, "includeKey": { "type": "boolean", "description": "Include encryption key in sync"