Skip to content

fix(schema): declare the dialect in $schema and the version in $id - #5011

Merged
mudler merged 1 commit into
kairos-io:masterfrom
ci-forks:bot/5010-schema-dialect
Sep 29, 2026
Merged

mudler merged 1 commit into
kairos-io:masterfrom
ci-forks:bot/5010-schema-dialect

Conversation

@ci-robbot

Copy link
Copy Markdown
Collaborator

Fixes #5010

Summary

kairos-agent print-schema wrote the document's own address into $schema:

$ kairos-agent print-schema | head -2
{
 "$schema": "https://kairos.io/v4.3.0/cloud-config.json",

$schema declares which JSON Schema dialect a document is written in, not where
the document lives. That is what $id is for. So a validator or an editor that
honours $schema fetches that value as a meta-schema, and nothing has been
published under https://kairos.io/ since v2.0.1 (only v1.6.x and v2.0.x are
checked into kairos-docs/static/), so the address 404s for every supported
release. The document also had no $id at all, and used draft-07's definitions
rather than $defs without declaring draft-07, so nothing in the output told a
consumer which dialect to read it as.

GenerateSchema now writes its second argument to $id, which names the
document, and sets $schema to the draft-07 meta-schema the reflector actually
emits. Both keys stay absent when that argument is empty, which is the form
KConfig.validate compiles, so kairos validate keeps the dialect it has today.
The version argument to JSONSchema keeps its meaning and its only caller,
print-schema, is unchanged.

Before and after, from the built binary:

$ kairos-agent print-schema --version v4.3.0 | head -3
{
 "$id": "https://kairos.io/v4.3.0/cloud-config.json",
 "$schema": "http://json-schema.org/draft-07/schema#",

This is the code half of the same defect as #4987, which fixed the docs half.

How it was tested

  • CGO_ENABLED=0 go test ./sdk/schema/ ./agent/pkg/cmd/ ./agent/pkg/config/...,
    67 specs in sdk/schema green.
  • Built the agent and ran the actual command, output above. jq confirms
    $id and $schema are set as intended and that the document still carries
    definitions and no $defs.
  • New spec compiles the printed document with santhosh-tekuri/jsonschema and
    validates config through it, so the declared dialect is checked to resolve the
    $ref targets the reflector emits rather than just asserted on a string. It
    accepts users[0].name: kairos and rejects users[0].name: 7 with
    "expected string, but got number".
  • Mutation check: restoring the old WithSchema(id) line turns exactly the five
    new specs red and leaves the other 62 green.
  • CGO_ENABLED=0 go build ./... clean over the whole tree, go vet clean,
    gofmt clean on the changed files. The one unrelated failure in sdk/sysext
    is this box having no docker daemon, not this change.

AI disclosure

Written by an automated agent (ci-robbot, operated by @mudler). No human has
read the code before this pull request was opened.

print-schema wrote the document's own address into $schema:

  "$schema": "https://kairos.io/v4.3.0/cloud-config.json"

$schema declares which JSON Schema dialect a document is written in, not
where the document lives. A validator that honours it fetches that value
as a meta-schema, and nothing has been published under https://kairos.io/
since v2.0.1, so the address 404s for every supported release. The
document also carried no $id, and used draft-07's "definitions" without
saying so, leaving a consumer nothing to read the references against.

GenerateSchema now writes its second argument to $id, which names the
document, and sets $schema to the draft-07 meta-schema the reflector
actually emits. Both keys stay absent when the argument is empty, which
is the form KConfig.validate compiles, so in-process validation keeps its
current dialect.

Signed-off-by: Ettore Di Giacinto <mudler@kairos.io>
@ci-robbot
ci-robbot requested a review from a team as a code owner September 27, 2026 06:10
@mudler
mudler merged commit d5d955f into kairos-io:master Sep 29, 2026
1 of 2 checks passed

This branch had an error being deployed

1 failed deployment
fork-pr-builds β€” 2917b6fd Deployed Sep 27, 2026 by ci-robbot via authorize #810
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

print-schema sets $schema to the schema's own 404ing URL, not to a meta-schema dialect

2 participants