Open
Conversation
fix(plugin-obsessiondb): zip array-form rows into objects in remote query()
The remote executor forwarded client.workbench.query.execute's res.data
straight through, but the workbench API returns rows as arrays (JSONCompact
shape) — e.g. ["name.sql", "2026-04-22 10:06:02.131", "c6eba240", "..."] —
not as objects keyed by column name. Every consumer in chkit (journal-store,
queryStatus, listSchemaObjects, listTableDetails) assumes the
ClickHouseExecutor.query<T>() contract from packages/clickhouse, which
returns objects. That contract was silently violated only for obsessiondb-
backed services.
The zod contract didn't catch it because z.record(z.unknown()) treats JS
arrays as valid records (their numeric-string keys pass validation).
Downstream effect in `chkit status`/`migrate`: journal rows mapped to
{ name: row.name, ... } produced undefined everywhere, so:
- appliedNames Set only contained undefined -> every disk file flagged
pending even when its name + checksum were already journaled
- applied count stayed correct (it's just rows.length)
- findChecksumMismatches hit existsSync(join(dir, undefined)) -> false,
silently skipped, reported 0 mismatches
Same failure mode breaks drift, check, and listSchemaObjects against
ObsessionDB. Locally-hosted ClickHouse via @clickhouse/client was unaffected
because it returns the default JSON format (object-keyed rows).
Fix: in remote-executor.ts query(), zip res.meta column names onto each row
when it comes back as an array, and pass object-form rows through unchanged
so a future server-side format change doesn't regress.
Added src/query/remote-executor.test.ts covering array-form zipping,
object-form passthrough, empty results, and error surfacing.
Contract at contract/workbench.ts is still overly permissive
(z.record(z.unknown()) accepts arrays) — left alone since the comment
says it'll be replaced by the upstream @obsessiondb/feature-workbench-
contract dep. Tightening should happen there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(plugin-obsessiondb): zip array-form rows into objects in remote query()
The remote executor forwarded client.workbench.query.execute's res.data straight through, but the workbench API returns rows as arrays (JSONCompact shape) — e.g. ["name.sql", "2026-04-22 10:06:02.131", "c6eba240", "..."] — not as objects keyed by column name. Every consumer in chkit (journal-store, queryStatus, listSchemaObjects, listTableDetails) assumes the ClickHouseExecutor.query() contract from packages/clickhouse, which returns objects. That contract was silently violated only for obsessiondb- backed services.
The zod contract didn't catch it because z.record(z.unknown()) treats JS arrays as valid records (their numeric-string keys pass validation).
Downstream effect in
chkit status/migrate: journal rows mapped to { name: row.name, ... } produced undefined everywhere, so:Fix: in remote-executor.ts query(), zip res.meta column names onto each row when it comes back as an array, and pass object-form rows through unchanged so a future server-side format change doesn't regress.
Added src/query/remote-executor.test.ts covering array-form zipping, object-form passthrough, empty results, and error surfacing.
Contract at contract/workbench.ts is still overly permissive (z.record(z.unknown()) accepts arrays) — left alone since the comment says it'll be replaced by the upstream @obsessiondb/feature-workbench- contract dep. Tightening should happen there.