Skip to content

[BUGFIX] Set ProxyKindName to the proxy kinds accepted by the schema - #132

Merged
Nexucis merged 1 commit into
mainfrom
nexucis/proxy-kind-name
Nov 19, 2026
Merged

Nexucis merged 1 commit into
mainfrom
nexucis/proxy-kind-name

Conversation

@Nexucis

@Nexucis Nexucis commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

This fixes the root cause of perses/perses#4775.

http.ProxyKindName and sql.ProxyKindName were "httpproxy" and "sqlproxy", but the schema only accepts "HTTPProxy" and "SQLProxy" (http_patch.cue and sql_patch.cue). Perses lowercases the kind of a proxy before comparing it with these constants, so they worked as matching keys. Since perses/perses#4077, the go-sdk also writes http.ProxyKindName in the kind of the proxy, so the schema rejects the datasources built with it. With the VictoriaLogs SDK from the issue:

spec.proxy.kind: conflicting values "HTTPProxy" and "httpproxy"

The constants now hold the kinds that the schema accepts:

  • Go: http.ProxyKindName is "HTTPProxy" and sql.ProxyKindName is "SQLProxy". Their new doc comment says to use them as the kind of a proxy.
  • CUE: #ProxyKindName in http_go_gen.cue and sql_go_gen.cue comes from make cue-gen. The patch files still define the accepted kinds, and don't change.
  • TypeScript: SQLProxy.kind was 'sqlproxy', so the schema rejected a value of this type too. It's now 'SQLProxy', like HTTPProxy.kind. No Zod schema covers the proxies.
  • Java has no proxy model, so it doesn't change.

Compatibility

The schema doesn't change, so the stored datasources and their validation don't change either.

Go code that compares a lowercased kind with these constants stops matching. Perses does it in pkg/model/api/v1/datasource/proxy.go and internal/api/discovery/cuetils/node.go. Built against this branch without other change, Perses doesn't find the proxy of a datasource anymore:

So Perses must not upgrade spec without the change described below.

Tests

  • TestMarshalJSONProxy (HTTP and SQL): a Proxy with the kind ProxyKindName marshals to "kind":"HTTPProxy" or "kind":"SQLProxy".
  • cue-test/datasource: a proxy with the kind http.#ProxyKindName or sql.#ProxyKindName satisfies #HTTPDatasourceSpec or #SQLDatasourceSpec.

On main, both fail, the CUE test with the same conflict as the issue. Both pass with this change.

These checks pass:

  • make checkformat, make checkunused, make checkstyle
  • make go-test
  • make cue-gen with CUE v0.16.1, like the CI: only #ProxyKindName and its comment change in the generated files
  • make cue-eval, make cue-test
  • In ts: npm run lint, npm run format:check, npm run type-check, npm test, npm run build

With spec v0.3.0, the go-sdk (http.New("http://localhost:9428")) builds {"kind":"httpproxy",...}, which cue vet -d '#HTTPDatasourceSpec' rejects. Against this branch, it builds {"kind":"HTTPProxy",...}, which cue vet accepts. A lowercase kind is still rejected.

Follow-up in Perses

perses/perses#4777 (draft) upgrades spec to the release containing this PR, assumed to be v0.4.0-beta.1. Its first commit compares the proxy kinds with strings.EqualFold instead of lowercasing them. It works with v0.3.0 too, so it can be merged first. With the upgrade, the go-sdk writes HTTPProxy, which fixes perses/perses#4775.

http.ProxyKindName and sql.ProxyKindName were "httpproxy" and
"sqlproxy", but the schema only accepts "HTTPProxy" and "SQLProxy".
Since perses/perses#4077, the Perses go-sdk writes http.ProxyKindName
in the kind of the proxy, so the schema rejects the datasources it
builds (perses/perses#4775).

The constants now hold the kinds accepted by the schema, and the
generated CUE follows. The TypeScript SQLProxy kind had the same
problem, so it is now 'SQLProxy', like the HTTPProxy kind.

Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Release sequencing needs maintainer confirmation because the exported constant changes can cause downstream destination and secret-permission checks to be skipped unless the still-draft fix in perses/perses#4777 is adopted before upgrading.

No open issues 🎉

What changed in this PR

Aligns datasource proxy kind values across Go, generated CUE, and TypeScript with the existing schema, allowing SDK-generated datasources to validate without changing accepted stored-resource formats.

Changes:

  • Sets Go proxy constants to HTTPProxy and SQLProxy, documents their use, and updates generated CUE definitions.
  • Corrects the TypeScript SQL proxy discriminator to SQLProxy.
  • Adds Go serialization and CUE validation regression tests for both proxy kinds.
File Description
ts/​src/​datasource/​proxy/​sql.ts Aligns the SQL proxy discriminator with the schema.
go/​datasource/​proxy/​sql/​sql.go Corrects and documents the SQL proxy kind constant.
go/​datasource/​proxy/​sql/​sql_test.go Tests serialization with the accepted SQL proxy kind.
go/​datasource/​proxy/​http/​http.go Corrects and documents the HTTP proxy kind constant.
go/​datasource/​proxy/​http/​http_test.go Tests serialization with the accepted HTTP proxy kind.
cue/​datasource/​proxy/​sql/​sql_go_gen.cue Reflects the corrected Go SQL proxy constant and comment.
cue/​datasource/​proxy/​http/​http_go_gen.cue Reflects the corrected Go HTTP proxy constant and comment.
cue-test/​datasource/​sql.cue Checks that the generated SQL kind satisfies the datasource schema.
cue-test/​datasource/​http.cue Checks that the generated HTTP kind satisfies the datasource schema.

Review effort: Max (adaptive)

@Nexucis
Nexucis added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 6a24b31 Nov 19, 2026
15 checks passed
@Nexucis
Nexucis deleted the nexucis/proxy-kind-name branch November 19, 2026 10:19
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.

Inconsistency between golang and cue in spec

3 participants