Skip to content

fix(query): pipeline resolver — handle column-keyed row objects#13

Merged
alexskatell merged 1 commit into
mainfrom
fix-pipeline-resolver-row-shape
May 14, 2026
Merged

fix(query): pipeline resolver — handle column-keyed row objects#13
alexskatell merged 1 commit into
mainfrom
fix-pipeline-resolver-row-shape

Conversation

@alexskatell
Copy link
Copy Markdown
Contributor

Why

Follow-up to #12. The v1.6.2 pipeline-name resolver shipped with a row-shape mismatch that made it silently fail against the real hosted warehouse:

$ topline --agent query audit --pipeline 'flex triage' --since this-week-et
no pipeline matched "flex triage". Available pipelines: (none found)

SELECT id, name FROM pipelines returns rows fine; the resolver simply didn't recognize the row shape.

Root cause

The hosted warehouse query API returns rows as column-keyed maps:

{"columns": ["id","name"], "rows": [{"id":"bna6...","name":"Sales - Flex - Triage"}]}

But selectIDNamePairs assumed positional arrays ([]any aligned with columns). Every row failed the r.([]any) type assertion and got silently skipped, leaving the resolver to report "(none found)".

The unit-test fixture in pipelineLookupServer also emitted positional arrays, so the mismatch slipped through CI.

Fix

  • selectIDNamePairs now switches on row type:
    • map[string]any → read row["id"] / row["name"] by column name.
    • []any → read by positional index (preserved for parity with any deployment that returns array rows).
  • Test fixture rewritten to emit the real column-keyed object shape — resolver tests now exercise the actual wire format.

Verified live

$ topline --agent query audit --pipeline 'flex triage' --since this-week-et --status open
{ "activity": { ... rewritten_sql: "...WHERE \"pipeline_id\" = 'bna6e9DoPgRchNsjeYS3'..." ... } }

Resolves cleanly to bna6e9DoPgRchNsjeYS3 (Sales - Flex - Triage) and runs the audit.

All existing resolver tests still pass.

PR #12's selectIDNamePairs assumed rows came back as positional arrays
([]any aligned with `columns`), but the live hosted warehouse query API
returns rows as column-keyed maps (map[string]any with "id" and "name"
keys). The unit-test fixture also returned positional arrays, so the
mismatch slipped through — verified against prod by running:

  topline --agent query audit --pipeline 'flex triage' ...

which returned `no pipeline matched ... Available pipelines: (none found)`
even though `SELECT id, name FROM pipelines` returned rows fine.

Fix
- selectIDNamePairs now switches on row type:
  - map[string]any: read row["id"] / row["name"] by column name.
  - []any: read by positional index (preserved for parity with any
    deployment that returns array rows).
- Test fixture in pipelineLookupServer rewritten to emit the real
  column-keyed object shape ({"id":"...","name":"..."}), so the
  resolver tests now exercise the actual wire format.

Verified live: `topline --agent query audit --pipeline 'flex triage' ...`
resolves to bna6e9DoPgRchNsjeYS3 (Sales - Flex - Triage) and runs the
audit cleanly.

All existing resolver tests still pass.
@alexskatell alexskatell merged commit 30d6587 into main May 14, 2026
1 check passed
@alexskatell alexskatell deleted the fix-pipeline-resolver-row-shape branch May 14, 2026 17:36
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.

1 participant