Skip to content

runtime: success encoding drops valid table row fields #320

Closed

Description

@allisonmahmood

Problem

Successful table operations can omit the generated row ID, timestamps and user columns from their HTTP 200 response. Legal user columns named ok and rows cause the generic runtime response encoder to select an unrelated Postgres result shape. Stored data remains intact.

Reproduction

At ef3e790, provision a table with ok:boolean, rows:json and title:text. Insert:

{"ok":true,"rows":[{"label":"ordinary nested value"}],"title":"Snapshot label"}

The operation-specific encoder produces the complete row. RuntimeApi returns only the matched Postgres-result fields, for example:

{"ok":true,"value":{"ok":true,"rows":[{"label":"ordinary nested value"}]}}

With an optional cursor column, cursor is retained too; it is not required to trigger the bug.

Independently exercised actual RuntimeApi HTTP serialization with real TableOperations, provisioning and PGlite, capturing raw response text. Proven affected operations: tables.insert, tables.get and tables.update. The same rows remain complete through tables.list, tables.getMany and tables.insertMany. Fourteen controls narrow the trigger to ok:true plus rows containing records or nulls; ok:false and nonmatching JSON shapes preserve the row. This is in-process HTTP-adapter proof, not browser/network end-to-end.

Minimal encoder reproduction, using the two actual codecs in that path:

import * as Schema from "effect/Schema";
import { RuntimeSuccess, runtimeOperations } from "./packages/api/src/runtime.ts";

const inserted = { id: "row-1", createdAt: "2026-09-21T00:00:00Z", updatedAt: "2026-09-21T00:00:00Z", ok: true, rows: [{ label: "ordinary nested value" }], cursor: null, title: "kept in storage" };
const operationValue = Schema.encodeSync(runtimeOperations["tables.insert"].response)(inserted);
const wireValue = Schema.encodeSync(RuntimeSuccess)({ ok: true, value: operationValue });
console.log(JSON.stringify({ operationValue, wireValue, lostKeys: Object.keys(operationValue).filter(key => !(key in wireValue.value)) }, null, 2));

Save at the repo root and run node --import tsx --conditions=development runtime-response-probe.ts. lostKeys includes id, createdAt, updatedAt and title.

Cause and proposed scope

RuntimeSuccess unions all operation response schemas. Runtime.handler has already encoded against the selected operation, but RuntimeApi encodes it again through this overlapping union. A table row matching a Postgres Struct loses extra keys.

Keep the selected operation codec through serialization, or use a lossless JSON envelope after operation-specific encoding. Preserve per-operation validation and the current wire shape. Reordering the union only moves the ambiguity.

A tool storing ordinary response snapshots cannot reliably use the returned row ID for its next update/delete. This is response data loss, not observed storage loss.

Found and independently reproduced by separate GPT-6 Astra agents in Oh My Pi. Ordinary offline product testing only.

Activity

  1. added
    bug
    needs-triage
    area:server
    area:primitives
    on Sep 20, 2026
  2. added a commit that references this issue on Sep 24, 2026
    47bbeaa
  3. added a commit that references this issue on Sep 24, 2026
    66364ac
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

    area:primitivesarea:serverbugneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions