Skip to content

Grafana gallery follow-ups from #598: empty session on first load, drift-test gaps, regeneration steps #599

Open

Description

@caohy1988

Follow-ups from reviewing #598 at 042fcd3. None of these block that PR; the first one is the most important.

1. A fresh gallery import can open filtered to empty-session events (important). In dashboards/grafana/gallery/bqaa-dashboard-efficiency-trial.gallery.json the Session variable's current selection is cleared (around line 1846) and its option query (around 1863) can return "". When the selection is unset, Grafana initializes it to "" and keeps it if that matches a returned option, so a single event with an empty session ID (which the SDK writer accepts) narrows the whole dashboard before the viewer picks anything. The trial dashboard explicitly selects All (bqaa-dashboard-efficiency-trial.json around line 323), so the two diverge: with session IDs "", known-1 and known-2, the trial counts 3 events on first load and the gallery counts 1. Suggest excluding "" from the four filter dropdown queries in the trial and regenerating the gallery, while keeping those events in panel queries so All still counts them, plus a first-load regression test with a blank option.

2. Drift tests collapse duplicate entries. tests/test_grafana_gallery_export.py indexes panels by id and variables and __inputs by name (around lines 157-167 and 330) without checking list lengths, so a duplicate inserted before the real entry is silently dropped. A second VAR_PROJECT input or project constant variable carrying a real project ID passes all 46 tests. Asserting raw counts or comparing ordered id/name lists would close it, as the __requires check already does.

3. Constant __inputs are only checked for type and value. Labels (what the import screen shows), descriptions and extra keys aren't pinned (around lines 329-353), so a later export could carry instance-identifying text there. Pinning the full expected dict, like DATASOURCE_INPUT, would cover this.

4. Panel nesting isn't compared. Flattening panels drops parent/child structure, so moving the Trace detail panel under a table panel or into a row still passes, even though viewPanel=19 would then have nothing to open. Comparing a parent map per panel would catch it.

5. JSON booleans compare equal to numbers. The recursive comparison (around line 147) treats true as equal to 1, so changing a target's format from 1 to true, which the BigQuery backend rejects, passes.

6. The hidden-footer allowance drops configuration. _panel_change_allowed (around lines 212-214) lets options.footer disappear from any table with a hidden footer. Panel 22's sum reducer is in fact dropped in the shipped gallery, not moved into field defaults as the comment says. Pinning that one migration exactly would keep further losses from slipping through.

7. The sanitization scan is narrow. test_gallery_holds_no_urls_credentials_or_hosts only blocks http(s)://, email-like strings and localhost, and _datasource_uids only sees dict-form datasource references. A scheme-less internal host, a private IP, or a string-form datasource UID added to both files passes. The shipped file passes stricter checks today.

8. README regeneration steps.

  • The steps don't say the exporting instance's data source must be named BigQuery with the plugin version from run_local.py. With the provided datasource.example.yaml name, the export comes out as DS_BQAA_BIGQUERY and the gallery tests fail.
  • The conversion redirects into the gallery file before jq parses the download, then removes the download unconditionally, so a truncated download leaves an empty gallery file, deletes the input, and still exits 0. Writing to a temporary file and replacing only on success would fix it.
  • The file table near the top of the README doesn't list the trial dashboard or the gallery export.

9. Older issue, not from #598: the trace link passes the literal session ID as var-session_id, and Grafana treats All there as its select-all token, so a session literally named All opens other sessions' traces. A dedicated exact-session parameter would avoid that.

Related: #598

Activity

  1. caohy1988 commented on Nov 30, 2026

    @caohy1988
    CollaboratorAuthor

    Follow-ups from #634 (at fc1deb4). None of these block it.

    • Data source refs. _datasource_refs (around tests/test_grafana_gallery_export.py:240) skips a null datasource. A panel and its target both set to null in both files still pass, even though Grafana would resolve them to the instance default. A legacy "${datasource}" string reference also got through in one check. Inspecting every present datasource key and requiring an object with an allowed uid would close both.
    • Hostname/IP scan. The scan (around lines 134-139 and 493) matches a fixed suffix list against the whole serialized file. It misses names like bq-proxy.analytics.example.co.uk or bq-proxy.analytics.svc, single-label hosts and IPv6 literals. It also flags valid content: a SQL path like JSON_VALUE(attributes, '$.resource.labels.app') and a description mentioning build 12.3.4.1. The committed files scan clean, so this only matters for future edits. Checking decoded string values in context, with a few positive and negative fixtures, would make it sturdier.
    • Int vs. float. _diff (around line 172) still treats 1 and 1.0 as equal. Requiring identical leaf types would also cover the bool special case.
    • README step 5. A zero-byte or whitespace-only download still passes jq (exit 0) and replaces the gallery with an empty file. A check that exactly one dashboard object was decoded, with panels as an array, before the mv would catch it. Also, a parse error leaves an empty converted.json behind. That's harmless since it's gitignored.
    • First-load test. The count assertion only runs on Overview, which ignores event_type. Adding panel 6 or 21 would cover blank event types under All.
  2. added a commit that references this issue on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions