BigQuery-Agent-Analytics-SDK icon indicating copy to clipboard operation
BigQuery-Agent-Analytics-SDK copied to clipboard

Added: Dashboard with Vercel config

Open Saherpathan opened this issue 6 months ago • 3 comments

Live Dashboard

Known Issue

The live deployment is currently facing a data connection issue with BigQuery, so analytics data may not load correctly on the hosted version. Local setup should work correctly after configuring valid Google Cloud credentials and environment variables.

Tech Stack React TypeScript Vite Node.js Google BigQuery Vercel

Saherpathan avatar May 11 '26 16:05 Saherpathan

Thanks for the thorough review and the patch, @caohy1988! I’ve merged your fixes for the SQL sanitization, ADC support, and data normalization into this branch. Much appreciated!

Full review on head 4705d2d.

I also prepared a connector fix, but I could not push directly to this PR's source branch: GitHub returned Permission to Saherpathan/BigQuery-Agent-Analytics-SDK.git denied to caohy1988. I pushed the fix commit to my fork instead:

  • Branch: caohy1988:fix/pr142-dashboard-connector
  • Commit: 05aa9f0 fix(dashboard): harden BigQuery data connector

That patch does four things: supports Vercel service-account env vars and local ADC / GOOGLE_APPLICATION_CREDENTIALS, validates Project/Dataset/Table identifiers before building SQL, normalizes BQ AA rows into the shape the UI expects (id, parent_id, type, label, latency, total_tokens), and fixes the local runbook to use npx vercel dev for /api.

Findings:

  1. High — /api builds SQL from unsanitized request headers. dashboard_v2/api/index.ts interpolates x-gcp-project-id, x-bq-dataset, and x-bq-table directly into a backticked table path. A malformed header containing a backtick can break out of the identifier and alter the query. Even if this is intended as BYO table input, the server must validate identifiers before composing SQL. The patch branch adds strict identifier validation and returns 400 for invalid table refs.
  2. High — the current BigQuery connector breaks local ADC and some Vercel env setups. The module eagerly constructs new BigQuery({ projectId, credentials: { client_email, private_key } }) even when GCP_CLIENT_EMAIL / GCP_PRIVATE_KEY are absent. That prevents the local .env guidance (GOOGLE_APPLICATION_CREDENTIALS=...) from working reliably, because the client is given a partial credentials object instead of falling back to ADC. The patch branch only passes explicit credentials when both service-account env vars are set; otherwise it lets the Google client use ADC / GOOGLE_APPLICATION_CREDENTIALS.
  3. Medium — the API returns raw BQ AA rows, but the UI expects graph-friendly fields that do not exist in agent_events. TraceTree keys nodes by node.id || node.trace_id, edges by parent_id, and labels/types by type / label; BQ AA rows use span_id, parent_span_id, event_type, agent, JSON content, JSON attributes, and JSON latency_ms. As a result, data can load successfully but render as disconnected node-N entries with zero tokens/latency. The patch branch normalizes rows server-side so the existing components can render real BQ AA telemetry.
  4. Medium — local setup docs say npm run dev, but that starts only Vite and does not run the Vercel /api function. The README's local path sends users to localhost:5173, where /api is not backed by the serverless function. For the BigQuery connector to run locally, the documented path should be npx vercel dev (usually localhost:3000) or the Vite dev server needs an explicit API proxy/server. The patch branch updates the runbook and keeps npm run dev documented as UI-only.
  5. Medium — the public deployment lets any visitor query any table the deployment service account can read. The frontend sends Project/Dataset/Table in headers and the backend trusts them. Even after identifier validation, a public Vercel URL plus a broadly-permissioned service account becomes a table browser for every BigQuery table that service account can access. For a public demo, either restrict the allowed project/dataset/table via env allowlist, or make the deployment private/authenticated. This can be follow-up if the service account is intentionally scoped to one demo table only, but the security model should be explicit in README.
  6. Low — package.json has a dead start script. "start": "node server.cjs" references a file that does not exist. The patch branch changes it to vite preview --host=0.0.0.0.

Verification on the patch branch:

  • npm ci -> clean, 0 vulnerabilities.
  • npm run lint -> clean (tsc --noEmit).
  • npm run build -> clean; Vite only emits the existing large-chunk warning for the dashboard bundle.
  • git diff --check -> clean.

Saherpathan avatar May 12 '26 05:05 Saherpathan

do you have an e2e demo recorded for this workflow? @Saherpathan

haiyuan-eng-google avatar May 12 '26 20:05 haiyuan-eng-google

This is the video demo: Local dashboard view

How to run locally

  1. Go to the dashboard app: cd dashboard_v2

  2. Install dependencies: npm install

  3. Set up BigQuery auth:

    • Place a service account JSON at dashboard_v2/service-account.json
    • Add the GCP_PROJECT_ID to .env
    • Or set:
      • GOOGLE_APPLICATION_CREDENTIALS
      • GCP_CLIENT_EMAIL
      • GCP_PRIVATE_KEY
  4. Start the app: npm run dev

  5. App will run on:

http://localhost:3000

Saherpathan avatar Jun 05 '26 21:06 Saherpathan