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

KusionStack / karpor / 38034575026
65%

Build:
DEFAULT BRANCH: main
Ran 10 Oct 2026 07:30AM UTC
Jobs 1
Files 68
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

10 Oct 2026 07:29AM UTC coverage: 63.801% (+0.1%) from 63.681%
38034575026

push

github

web-flow
fix: stop rejecting valid NL-search SQL that contains the word error (#855)

## What type of PR is this?

/kind bug

## What this PR does / why we need it:

Natural language search returns a false "query is invalid" error
(rendered as an HTTP 500) for queries like "Which pods are in error
state", while other queries succeed.

The root cause is in `ConvertTextToSQL`
(`pkg/core/manager/ai/search.go`): it validated the LLM's raw response
with `IsInvalidQuery`, which flagged the response as invalid whenever it
contained the case-insensitive substring `"error"` **anywhere** in the
text. A query about pod error state legitimately produces a generated
SQL statement whose `WHERE` clause itself contains the word "error"
(matching a Kubernetes pod status value), so this substring check
rejected perfectly valid SQL as invalid.

`ConvertTextToSQL` now uses "was a `SELECT` statement extracted from the
response" as the sole validity signal, since the prompt (`prompt.go`,
`Text2sqlType`) already instructs the model to always emit SQL starting
with `select * from` and ending with `;`, or the literal word `"Error"`
when it cannot produce a query. The now-unused `IsInvalidQuery` helper
and its test were removed since nothing else in the repo referenced it.

**Validation:**
- `go build ./pkg/core/manager/ai/...` passes.
- `go test ./pkg/core/manager/ai/... -run TestConvertTextToSQL -v`
passes. The new `TestConvertTextToSQL/ValidQueryWithErrorAsValue` case
reproduces the reported bug: confirmed by stashing this change and
re-running the same test, which fails with `query is invalid` on the old
code and passes after this fix.
- `gofmt -l` on all changed files reports no issues.
- Could **not** run this repo's `make test` / `make lint` targets to
completion: the local machine's disk is almost entirely full (roughly
300-900Mi free on a 228Gi volume), and `pkg/core/manager/ai`
transitively depends on `k8s.io/kubernetes/pkg/apiserver` through
`pkg/kubernetes/registry`, which ... (continued)

3 of 3 new or added lines in 1 file covered. (100.0%)

4394 of 6887 relevant lines covered (63.8%)

0.7 hits per line

Jobs
ID Job ID Ran Files Coverage
1 38034575026.1 10 Oct 2026 07:30AM UTC 68
63.8
GitHub Action Run
Source Files on build 38034575026
  • Tree
  • List 68
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • cd5a1110 on github
  • Prev Build on main (#29180163372)
  • Next Build on main (#38044415156)
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