Skip to content

feat(cli): add warehouse tables layout get - #7690

Merged
bnjjj merged 6 commits into
feat/generated-warehouse-commandsfrom
bnjjj/pipe-1455-warehouse-tables-layout-get
Nov 18, 2026
Merged

bnjjj merged 6 commits into
feat/generated-warehouse-commandsfrom
bnjjj/pipe-1455-warehouse-tables-layout-get

Conversation

@bnjjj

@bnjjj bnjjj commented Nov 18, 2026 •

Copy link
Copy Markdown

Generate warehouse tables layout get <table-id> from GET /v2/projects/{ref}/warehouse/tables/{table_id}/layout. It reads one replicated table by the source OID that warehouse tables list shows, and reports two layouts side by side:

  • desired: the saved sorting and partitioning rules, where null means unmanaged and { "kind": "none" } or [] is an explicit clear;
  • observed: the sort expressions and partition keys the DuckLake catalog records, with the time they were read and an observation_status of observed, table_missing or unavailable.

The two can differ until the replicator applies saved rules, and a catalog layout does not establish that existing files are sorted or partitioned. Text output shows both as nested tables. A table that isn't replicated is an API error.

sort_by is the first nullable oneOf in the specification. The API client generator now adds null to a nullable oneOf as it already did for anyOf, so the typed client accepts a table with unmanaged sorting. The bindings test's schema fingerprint also reads a null union branch as a nullable type.

The layout contract comes from OpenAPI overrides until it ships in the deployed Management API specification.

Stacked on #7640, after #7689. Depends on https://github.com/supabase/platform/pull/42055 and https://github.com/supabase/platform/pull/42126.

Implements PIPE-1455.

Add the generated `warehouse tables list` command for the Management API
tables listing, and the matching `flush_lag_bytes` replication feedback in
the Warehouse status contract. Both contracts come from spec overrides until
the deployed specification includes them.

Render an empty resource collection as `No results` and leave out columns
that hold nested objects in any row, so nullable nested values no longer
print as compact JSON in the table.
Add the generated `warehouse tables get <table-id>` command for reading one
replicated table by its source OID. The contract comes from a spec override
until the deployed specification includes it.

The bindings coverage test now supplies positional path parameters.
Base automatically changed from bnjjj/pipe-1451-warehouse-tables-list to feat/generated-warehouse-commands November 18, 2026 15:55
…s' into bnjjj/pipe-1455-warehouse-tables-layout-get

# Conflicts:
#	apps/cli/src/cli/command-surface/command-surface.integration.test.ts
#	apps/cli/src/commands/api/api-command-policy.ts
#	apps/cli/src/commands/api/api-commands.integration.test.ts
#	apps/cli/src/commands/api/generated.md
#	apps/cli/src/commands/api/generated.schemas.ts
#	apps/cli/src/commands/api/generated.ts
#	packages/api/scripts/openapi-overrides.json
#	packages/api/src/generated/contracts.ts
#	packages/api/src/generated/effect-client.ts
#	packages/api/src/generated/openapi.json
#	packages/api/src/generated/permissions.ts
@bnjjj
bnjjj marked this pull request as ready for review November 18, 2026 16:13
@bnjjj
bnjjj requested review from a team and supabase-oss as code owners November 18, 2026 16:13
@bnjjj
bnjjj requested review from jgoux and removed request for a team November 18, 2026 16:13
@bnjjj
bnjjj merged commit b21f084 into feat/generated-warehouse-commands Nov 18, 2026
16 checks passed
@bnjjj
bnjjj deleted the bnjjj/pipe-1455-warehouse-tables-layout-get branch November 18, 2026 16:15

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

Confirmed all three findings. The exported OpenAPI document rejects the new Warehouse layout response when sorting is unmanaged, even though the generated Effect contract accepts it. The shared generator also introduces an edge case for unions that already accept null, and the CLI integration test does not cover a missing catalog layout. The CLI reference guidance artifacts were unavailable, so no style pass was performed.

Findings

Severity Location Category Sources Claim
🟠 MAJOR packages/api/scripts/openapi-overrides.json:1698 api-contract codex The exported OpenAPI 3.0 document rejects desired.sort_by: null, even though null is a valid response meaning sorting is unmanaged.
🟡 MINOR packages/api/scripts/generate.ts:337 code-generation codex Appending null directly to a oneOf can make the union reject null when exactly one original branch already accepted it.
⚪ NIT apps/cli/src/commands/api/api-commands.integration.test.ts:506 test-coverage claude The new integration test covers only a populated observed object. It does not verify that the CLI still displays the desired rules when the catalog layout is unavailable and observed is null.

Stats

Claude findings: 1 · Codex findings: 2 · Confirmed: 3 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment on lines +1698 to +1701
"sort_by": {
"description": "Configured sort order. none explicitly clears sorting, primary_key sorts by the source primary-key columns in key order, and columns lists them. Null leaves sorting unmanaged.",
"nullable": true,
"oneOf": [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MAJOR · api-contract · source: codex

The exported OpenAPI 3.0 document rejects desired.sort_by: null, even though null is a valid response meaning sorting is unmanaged.

Evidence: The override sets nullable: true next to oneOf without a sibling type. packages/api/src/generated/openapi.json:49509 preserves that shape, and all three branches require objects. The fixture at apps/cli/src/commands/api/api-commands.integration.test.ts:493 sends null.

Suggested fix: Replace the outer nullable flag with an explicit OpenAPI 3.0 null-only branch, such as {"type":"string","nullable":true,"enum":[null]}. Regenerate and validate the fixture against the exported document.

Comment on lines +337 to +343
: Array.isArray(sanitized.oneOf)
? "oneOf"
: undefined;
if (sanitized.nullable === true && sanitized.type === undefined && union !== undefined) {
const normalized = {
...sanitized,
anyOf: [...sanitized.anyOf, { type: "null" }],
[union]: [...(sanitized[union] ?? []), { type: "null" }],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MINOR · code-generation · source: codex

Appending null directly to a oneOf can make the union reject null when exactly one original branch already accepted it.

Evidence: packages/api/scripts/generate.ts:343 appends a null branch without checking the original branches. A oneOf with a nullable string branch and an integer branch goes from one match for null to two. The test at packages/api/scripts/generate.unit.test.ts:278 only covers branches that cannot accept null.

Suggested fix: If the generator must support this shorthand, wrap the intact oneOf and a null branch in an outer anyOf. Add a test that decodes null when one original branch is already nullable.

Comment on lines +506 to +521
it.effect("renders unmanaged desired sorting beside the observed catalog layout", () => {
const { out, sent, run } = setup(["warehouse", "tables", "layout", "get", "16385"], {
route: ok(body),
stdoutIsTty: true,
});
return Effect.gen(function* () {
yield* run;
expect(sent).toEqual([{ method: "GET", path: layoutPath, search: "", body: undefined }]);
expect(out.stdoutText).toMatch(/^Warehouse table layout\n/);
expect(out.stdoutText).toMatch(/Desired\n\s+Sort by\s+-\n/);
expect(out.stdoutText).toMatch(/account_id \| \{"kind":"bucket","count":16\}/);
expect(out.stdoutText).toMatch(/Observation status\s+observed/);
expect(out.stdoutText).toMatch(/account_id \| bucket\(16\)/);
expect(out.stdoutText).toMatch(/Observed at\s+2026-11-18T09:30:00\.123456Z/);
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ NIT · test-coverage · source: claude

The new integration test covers only a populated observed object. It does not verify that the CLI still displays the desired rules when the catalog layout is unavailable and observed is null.

Evidence: apps/cli/src/commands/api/api-commands.integration.test.ts:496 sets the status to observed and supplies a populated object. packages/api/src/generated/contracts.ts:15315 allows null, and packages/api/scripts/openapi-overrides.json:1771 documents when it occurs.

Suggested fix: Add a text-mode case with observation_status: "table_missing", observed: null, and desired: { sort_by: { kind: "none" }, partition_by: [] }. Assert that the output still shows the desired rules and renders Observed as -.

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