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

kcl-lang / kcl-openapi / 33316880738
64%

Build:
DEFAULT BRANCH: main
Ran 30 Aug 2026 02:27PM UTC
Jobs 1
Files 18
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

30 Aug 2026 02:26PM UTC coverage: 64.293% (+0.2%) from 64.044%
33316880738

push

github

web-flow
fix(generator): emit valid KCL from CEL x-kubernetes-validations (#167)

fix(generator): emit valid KCL from CEL `x-kubernetes-validations`

The translator introduced in #161 produced `check:` blocks that did not
compile under KCL: every `self.X` reference was left intact (KCL `check:`
blocks have no `self` in scope), `has(self.X)` was rendered as the
unsupported `(has self.X)` form, and `cond ? a : b` was emitted as
`a if cond else b` — which KCL's parser rejects inside a schema check
(the `else` token is treated as a bare name there).

Reported downstream by kcl-lang/modules PR #401, where the workaround
was to drop the whole `check:` block on regen. This commit makes the
translation faithful enough to keep the rules:

- Strip `self.` from field accesses (`emitSelect`).
- Map `has(self.X)` to `(X != None)`; `has(m.X)` for non-`self`
  operands is now unsupported because KCL cannot express it.
- Map `size(self)` to unsupported (KCL has no handle on the schema
  instance inside `check:`); `size(self.x)` still becomes `len(x)`.
- Surface CEL ternary inside `check:` as unsupported (the caller drops
  the rule).

The propagated `regex` import for `.matches(...)` rules is also fixed
so the header carries `import regex` and `_regex_match = regex.match`
whenever a CEL check uses `matches()` (previously only triggered by
JSON Schema `pattern`, leaving `check:` blocks referencing an undefined
identifier).

The `TestGenerate_OAI2KCL_K8sValidations` e2e test now also invokes
`kcl` on the generated file (via a new `lookupKCLBinary` helper that
falls back through `$KCL_BIN`, `$PATH`, and the homebrew install path)
so any future regression to invalid KCL fails CI rather than passing
on string-substring matches alone.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

34 of 37 new or added lines in 2 files covered. (91.89%)

2690 of 4184 relevant lines covered (64.29%)

0.72 hits per line

Uncovered Changes

Lines Coverage ∆ File
3
65.19
2.73% pkg/swagger/generator/cel.go
Jobs
ID Job ID Ran Files Coverage
1 33316880738.1 30 Aug 2026 02:27PM UTC 18
64.29
GitHub Action Run
Source Files on build 33316880738
  • Tree
  • List 18
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 3550e2b0 on github
  • Prev Build on main (#33304187079)
  • 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