Go SDK: labelvalues.Datasource("$var") emits typed struct instead of raw variable reference, breaking variable queries
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Start at labelvalues.Datasource and promDatasource.Selector in the Go SDK datasource package, then compare the emitted JSON with the raw-string representation confirmed by PR #775. Reproduce the PrometheusLabelValues example and trace how the selector is marshaled. Done means datasource variable references serialize as a bare "$datasource" string while typed datasource selectors remain supported.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
When building Perses dashboards programmatically with the Go SDK, calling labelvalues.Datasource("$datasource") to bind a PrometheusLabelValuesVariable to the selected datasource variable produces output that silently breaks all variable queries.
What the SDK emits (wrong)
"datasource": {
"kind": "PrometheusDatasource",
"name": "$datasource"
}
What Perses requires for a variable reference (correct)
"datasource": "$datasource"
PR #775 already confirmed this is the correct representation for datasource variable references. The CUE schema for spec.datasource is a disjunction that allows either a raw $variable string or a typed struct — but only the raw string triggers variable substitution at runtime.
Consequence
When the typed struct form is used with a variable name, Perses resolves it as a literal datasource name lookup. Since no registered datasource is named "$datasource", every label-values variable query returns no data — silently, with no visible error in the dashboard.
Steps to reproduce
labelvalues.PrometheusLabelValues("region",
labelvalues.Datasource("$datasource"),
labelvalues.Matchers("my_metric"),
)
Produces:
{
"kind": "PrometheusLabelValuesVariable",
"spec": {
"datasource": { "kind": "PrometheusDatasource", "name": "$datasource" },
"labelName": "region",
"matchers": ["my_metric"]
}
}
All region variable queries return no data.
Root cause
labelvalues.Datasource(name) calls promDatasource.Selector(name) which returns &datasource.Selector{Kind: PluginKind, Name: name}. This struct always serializes as the typed object form — there is no code path in the SDK to emit a bare "$variable" string.
Suggested fix
One of:
- In
github.com/perses/perses/go-sdk/datasource, add a customMarshalJSONtoSelectorthat emits a plain string whenNamematches^\$\w+$andKindis empty. - Add a new option
labelvalues.DatasourceVariable(variableName string)in this package that setsspec.datasourceto the raw string"$variableName"instead of constructing aSelectorstruct.
Related
- perses/plugins#775 — confirmed the typed struct is wrong for variable references (migration fix)
- perses/perses#3407 — runtime failure when using a datasource variable in variable plugin specs
- Lingua principale
- TypeScript
- Stelle
- 33
- Fork
- 88
- Merge medio
- 2g 43m
- PR unite (30g)
- 34
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di perses/plugins
-
[BUG] clickhouse: getTimeSeriesData drops dimension columns, collapsing long-format results into one seriesForse già presa @aminadojava l’ha presa 23 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] clickhouse: FORMAT substring check, envelope fallback and swallowed errorsForse già presa @Yash121l l’ha presa 11 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
perses/plugins#842 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
perses/plugins#501 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Module federation warnings "No required version specified"Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di perses/plugins
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
cloudscape-design/components#5184 ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
JarX-Concepts/react-native-platform-components#130 ·
I maintainer di solito rispondono entro 1 giorno
-
fix(api): optimize-for-web /preview outer catches miss asDecoderOutOfMemory on V8 OOM and SIGKILLApertaarea: backend bug priority: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
snapotter-hq/SnapOtter#3773 ·
I maintainer di solito rispondono entro 1 giorno
-
ai-driven-qa ux-audit
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
linagora/twake-contacts-frontend#386 ·
I maintainer di solito rispondono entro 1 giorno
-
git: README should state plainly that without --repository every reachable repository is in scopeApertadocumentation server-git v2
Difficoltà 1/5 1-3 ore Idoneità per principianti 84/100
modelcontextprotocol/servers#5225 ·
I maintainer di solito rispondono entro 1 giorno