Skip to content

EditV2Input type sends wrong field names — revision/ops vs server's baseRevision/operations #22

@galligan

Description

@galligan

The short version

The EditV2Input type in @proof/agent-bridge uses revision and ops as field names, but the server's editV2 handler (agent-edit-v2.ts) expects baseRevision and operations. Calls through client.editV2() silently fail — the server sees undefined for both fields and returns a 400.

What's happening

In packages/agent-bridge/src/types.ts:

export interface EditV2Input {
  by: string;
  revision: number;      // ← server expects `baseRevision`
  ops: EditV2BlockOp[];  // ← server expects `operations`
  idempotencyKey?: string;
}

The editV2() method in the bridge client (packages/agent-bridge/src/index.ts) sends this payload as-is via JSON.stringify(input). No field remapping happens.

Meanwhile, the server handler in server/agent-edit-v2.ts reads:

const operationsRaw = Array.isArray(payload.operations) ? payload.operations : [];
const baseRevision = typeof payload.baseRevision === 'number' ? payload.baseRevision : null;

So payload.revision and payload.ops are never read — the server gets an empty operations array and a null baseRevision, then returns "baseRevision is required".

Workaround

Build the request body manually with the correct field names and POST directly to /documents/:slug/edit/v2. That's what I ended up doing in proof-sdk-cli after hitting this.

Suggested fix

Rename the fields in EditV2Input to match the server:

export interface EditV2Input {
  by: string;
  baseRevision: number;
  operations: EditV2BlockOp[];
  idempotencyKey?: string;
}

This is a breaking change for anyone currently constructing EditV2Input objects, but since the current interface doesn't actually work against the server, the practical impact should be minimal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions