Go SDK: labelvalues.Datasource("$var") emits typed struct instead of raw variable reference, breaking variable queries
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 33
- Forks
- 91
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 37
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de perses/plugins
-
[BUG] splunk: export parsing, job polling and missing values are not handled robustlyPosiblemente ocupada @AnKiT-GaRG2 la tomó hace 1 día. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
[BUG] clickhouse: getTimeSeriesData drops dimension columns, collapsing long-format results into one seriesPosiblemente ocupada @aminadojava la tomó hace 29 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 58/100
Los mantenedores suelen responder en 1 día
-
[BUG] clickhouse: FORMAT substring check, envelope fallback and swallowed errorsPosiblemente ocupada @Yash121l la tomó hace 18 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
perses/plugins#842 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
perses/plugins#501 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de perses/plugins
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
marmelab/react-admin#11431 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
db-ux-design-system/core-web#8655 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
stripe/react-stripe-js#728 ·
-
[Upload Grade C dataset] the pop-up changes it's size while uploading the document => Jumping effectAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
epam/statgpt-admin-frontend#305 ·
Los mantenedores suelen responder en 1 día