Repository navigation
feat(lint): use the schema from meta.upsun.com for Flex and Fixed config - #248
Conversation
…schema The Flex config schema now comes from https://meta.upsun.com/schema/upsun (the upsun/meta repository), which was synced with the CLI's copy in upsun/meta#220. Schema changes are made there first. - Add `make update-schema` (internal/lint/schema/gen.go), which fetches the schema and indents it, and `make check-schema`, run in the non-blocking upstream CI job beside `check-registry` (renamed `lint-upstream`). - Replace the schema's remote $refs (runtime-versions, service-versions) with empty schemas when loading, so lint does not need the network. Types are checked against the registry by CheckTypes. A test fails if the schema gains another remote $ref. - Report the schema's "maxItems: 0" error on a stack list with the same message as checkStackList. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning
🔍 Full review · 10 files reviewed
Verification
compileregisters both remote$refURLs as{}withAddSchemabeforeCompile, andTestSchemaKeywordsfails on any remote$refnot listed inremoteRefs.- The
array_max_itemsrewrite inCheckSchemaAtcannot misfire elsewhere:maxItemsappears only once in the Flex schema (ondefinitions.stack), and the Fixed schemas have none. - With the stubbed refs, the new
typeanyOf/allOf branches always pass, so type messages still come only fromCheckTypes. check-schemadiffs onlyupsun-config-schema.jsonaftergen.gorewrites it, and the!cancelled()condition lets it run even whencheck-registryfails.
New coverage: one TestLint_ContainerFeatures case (a task stack list plus a cron timeout error), and an extended TestSchemaKeywords remote-ref assertion, both run by make test-go in the CI test job. Schema freshness is checked by make check-schema in the non-blocking lint-upstream job. No test combines a stack list with a semantic (non-schema) error.
Review details
- Commit: d59cd29
- Model: claude-opus-5-5
Review 1 of 10 for this pull request · View the full run
…ill run A schema error stops CheckContent before the semantic checks, so reporting the schema's "maxItems: 0" stack error hid every other error until the stack was fixed. The schema error is now skipped, and checkStackList reports the stack list with the other errors, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the upstream schema's "maxItems: 0" error for a non-empty stack list, rather than skipping it for checkStackList, which now only reports stack lists in Fixed config. As with any schema error, the semantic checks run once it is fixed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Reviewed — No blocking findings · 🔵 1 minor point
🔁 Incremental · 2 files reviewed
🔵 Minor point
internal/lint/linter_test.go:409— With thearray_max_itemsskip removed fromCheckSchemaAt, a non-empty stack list is now reported differently depending on the config style. A Flex config (stack: ["php@8.4"]in.upsun/) gets the generic schema messageapplications.app.stack: Array must have at most 0 items, andCheckContentreturns beforerunChecks. The same list in a Fixed.platform.app.yamlpasses the Fixed schema, which has nomaxItems, and reachescheckStackListin types.go. That prints'stack' must be a mapping of 'runtimes' and 'packages', not a list(fixed_test.go:167). For Flex configs,checkStackListcan no longer see a non-empty list, so its explanatory message is effectively Fixed-only.
Verification
- The
stringsimport in yaml.go is still used afterisStackFieldis removed (TrimPrefix, HasPrefix, Contains). checkStackListstill runs for Fixed configs: the Fixed application schema allows a stack array with nomaxItems, so its fixed_test.go expectation still holds.- The updated
stack listtest case expects the raw gojsonschemaarray_max_itemsmessage, which matches whatCheckSchemaAtnow emits with the skip gone.
Covered by the updated TestLint_ContainerFeatures stack list case in internal/lint/linter_test.go. The test that combined a stack list with a semantic error was removed, so no test now checks how a stack-list error interacts with the semantic checks. The Go test job in .github/workflows/ci.yml runs these tests.
Review 3 of 10 for this pull request · View the full run
The platform validates Fixed and Flex config with the same models, so Fixed config is now checked with the upstream Flex schema, patched by fixed-overlay.json (a JSON Merge Patch), instead of three schemas maintained here, which had fallen behind (e.g. post_start, dynamic_compression, runtime extensions). The overlay adds the keys that only Fixed config accepts: `disk` on applications, web, workers and services, an application `size` and `name` (required, as on the platform), and `build.caches`. Behavior changes for Fixed config, matching Flex and the platform: - `firewall` is rejected (deprecated in favor of `egress`). - `type` is required, also with a `stack`. - A non-empty stack list gets the schema's error, so checkStackList and the stack-without-type warning are removed. The schema tests now also check the patched schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning
🔁 Incremental · 12 files reviewed
Verification
- Every path the overlay patches (applications.additionalProperties, build, web, workers.additionalProperties, services.additionalProperties) is inline in the Flex schema, not a
$ref, so the merged keywords take effect. subSchemacopies the rootdefinitionsand$schemainto each Fixed sub-schema, so#/definitions/fixed/*and the Flex#/definitions/stackrefs resolve.compilestill replaces the remote version refs.- The Flex application
anyOfrequirestype, so dropping the stack-without-type branch fromCheckTypescan't let an untyped Flex app reachcheckRuntime. - The Flex services schema already has
sizeandresources, so these Fixed service keys stay valid without an overlay entry.
This push adds table cases to fixed_test.go (Fixed-only keys, firewall, invalid size, stack list, stack without type) and to linter_test.go. schema_test.go now runs the defaults and keyword checks on the patched schema too. These run under make test-go in CI. Nothing compares the overlay with the platform's real Fixed model, so keys accepted there and missing from the overlay go unnoticed.
Review 4 of 10 for this pull request · View the full run
Since upsun/meta#220, the schema served at
https://meta.upsun.com/schema/upsunmatches the CLI's copy, so the CLI now takes it from there. Schema changes are made in upsun/meta first.Flex
make update-schemafetches the schema and indents it (internal/lint/schema/gen.go, like the registry'sgen.go).make check-schemaruns in the non-blocking CI job besidecheck-registry, renamedlint-upstream.$refs (runtime-versions,service-versions) are replaced with empty schemas when loading, solintdoes not fetch them over the network. Types are already checked against the registry byCheckTypes, with clearer messages. A test fails if the schema gains another remote$ref.stacklist is reported by itsmaxItems: 0("Array must have at most 0 items").Fixed
The platform validates Fixed and Flex config with the same models, differing only in a few keys. Fixed config is now checked with the same schema, patched by
internal/lint/schema/fixed-overlay.json(a JSON Merge Patch), in place of the threeplatformsh.*.jsonschemas maintained here, which had fallen behind (e.g.post_start,dynamic_compression, runtime extensions).diskon applications, web, workers and services, an applicationsizeandname(required, as on the platform), andbuild.caches.firewallis rejected in both styles, as it is deprecated in favor ofegress.typeis now required for Fixed apps with astack, as on the platform, and a stack list gets the schema's error.checkStackListand the stack-without-type warning are removed.$ref, dot-key patterns) also run on the patched schema.🤖 Generated with Claude Code