• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kcl-lang / kcl-go / 33409544911
29%
main: 29%

Build:
Build:
LAST BUILD BRANCH: fix/jsonschema-if-type-guard
DEFAULT BRANCH: main
Ran 31 Aug 2026 03:38PM UTC
Jobs 6
Files 103
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

31 Aug 2026 03:36PM UTC coverage: 29.378% (+0.1%) from 29.267%
33409544911

Pull #589

github

Peefy
feat(gen): support type-only if conditions in JSON Schema import (fixes kcl-lang/kcl#1876)

A JSON Schema `if` subschema that consists only of a `type` keyword —
the common `if: {type: "string"}` guard on properties declared as
`type: ["string", "null"]` — produced no KCL expression, so the whole
if/then/else triple was dropped with a
"[WARN] unsupported if condition" and the `then` constraints (e.g.
`maxLength: 255`) were silently lost.

Emit the guard as `typeof(field) == "<type>"`, but only when the
enclosing schema itself declares a union type: for a single-typed
field the property declaration already enforces the type and a typeof
check would spuriously fail for int literals assigned to float fields.

Related fixes in the same area:

- validator.gotmpl: `{{if $then}}`/`{{if $else}}` test the condResult
  struct, which is always truthy, so a triple with a usable `then` and
  no `else` rendered a dangling ` if not (...)` check with an empty
  left-hand side. Test `.Expr` instead.
- condExpr: skip the redundant truthiness guard when the condition is
  a typeof check, which is already False for None, avoiding
  `... if typeof(f) == "str" and f`.
- document why `null` stays out of type unions: KCL has no `None` type
  annotation; nullability is expressed with the `?` modifier.

Also add a cgo-gated test that executes the generated schema and
asserts the semantics: None stays valid, an over-long string is
rejected, and the $ref'd default applies.

Signed-off-by: Peefy <peefy@qq.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pull Request #589: feat(gen): support type-only if conditions in JSON Schema import

39 of 50 new or added lines in 2 files covered. (78.0%)

7 existing lines in 2 files now uncovered.

4867 of 16567 relevant lines covered (29.38%)

2.02 hits per line

Uncovered Changes

Lines Coverage ∆ File
11
72.17
-0.32% pkg/tools/gen/genkcl_jsonschema.go

Coverage Regressions

Lines Coverage ∆ File
5
72.17
-0.32% pkg/tools/gen/genkcl_jsonschema.go
2
81.5
-1.16% pkg/format/xml/xml.go
Jobs
ID Job ID Ran Files Coverage
1 33409544911.1 31 Aug 2026 03:38PM UTC 103
29.38
GitHub Action Run
2 33409544911.2 31 Aug 2026 03:38PM UTC 103
29.38
GitHub Action Run
3 33409544911.3 31 Aug 2026 03:38PM UTC 103
29.38
GitHub Action Run
4 33409544911.4 31 Aug 2026 03:38PM UTC 103
29.38
GitHub Action Run
5 33409544911.5 31 Aug 2026 03:40PM UTC 103
29.38
GitHub Action Run
6 33409544911.6 31 Aug 2026 03:40PM UTC 103
29.38
GitHub Action Run
Source Files on build 33409544911
  • Tree
  • List 103
  • Changed 4
  • Source Changed 0
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Pull Request #589
  • PR Base - main (#33364285076)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc