Skip to content

Commit 53bec3a

Browse files
committed
fix(rest): an export of an unknown object name is a refusal and writes no audit row
Seat decision on the contract review of the export audit row: an object name the registry does not know means no object and no data moved, and the name is only the caller's path text, so the export catch hands no event for OBJECT_NOT_FOUND. The door pin flips to 404 with no event, beside a control export of a known object on the same boot. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibwj6uu1L1hVh8hXHro
1 parent e1d50d5 commit 53bec3a

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

‎packages/rest/src/data-action-routes.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,8 +1784,12 @@ export function registerDataActionEndpoints(this: DataActionRouteHost, basePath:
17841784
// machine code the shared resolver reads off the error —
17851785
// never the error's text, which a driver can fill with a
17861786
// comparand.
1787+
// An object name the registry does not know is the one read
1788+
// refusal that writes no row: no object, so no data moved, and
1789+
// the name is only the caller's path text, unverified.
17871790
if (exportRun) {
17881791
const { status, code } = resolveThrownHttpError(error, 500);
1792+
if (code === 'OBJECT_NOT_FOUND') return;
17891793
await recordDataExport(this, environmentId, req, {
17901794
...exportRun,
17911795
truncated: exportTruncatedAtLimit(exportRun.rowCount, exportRun.limit, exportLastPage),

‎packages/rest/src/export-integration.test.ts‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,11 @@ describe('[#30955] export route — the ledger hears of every export it streams'
869869
expect(events[0].errorCode).toBe('INVALID_FIELD');
870870
});
871871

872-
it('an export of an object name the registry does not know, past an export gate that let it through, hands ONE failed event (404 OBJECT_NOT_FOUND)', async () => {
873-
// Pinned as built, for the review to judge: the gates passed and the read
874-
// began, so by the door's one rule this is an export that failed, not a
875-
// refusal. Only a caller the export gate admits for that name reaches it.
872+
it('an export of an object name the registry does not know, past an export gate that let it through, is a refusal: 404 OBJECT_NOT_FOUND and no event', async () => {
873+
// Seat decision on the contract review: no object, so no data moved, and
874+
// the name is only the caller's path text — it is never written to the
875+
// ledger as an `object_name`. Only a caller the export gate admits for
876+
// that name reaches this branch.
876877
const gateAsked: string[] = [];
877878
const { events, run } = await bootAudited({
878879
canExport: async (object) => { gateAsked.push(object); return true; },
@@ -881,15 +882,11 @@ describe('[#30955] export route — the ledger hears of every export it streams'
881882
expect(answer.status).toBe(404);
882883
expect(answer.json?.code ?? answer.json?.error?.code).toBe('OBJECT_NOT_FOUND');
883884
expect(gateAsked).toEqual(['no_such_object']);
885+
expect(events).toEqual([]);
886+
// Control on the same boot: a known object still hands its event.
887+
expect((await run('task', { format: 'csv' })).status).toBe(200);
884888
expect(events).toHaveLength(1);
885-
expect(events[0]).toMatchObject({
886-
objectName: 'no_such_object',
887-
outcome: 'failed',
888-
status: 404,
889-
errorCode: 'OBJECT_NOT_FOUND',
890-
rowCount: 0,
891-
truncated: false,
892-
});
889+
expect(events[0]).toMatchObject({ objectName: 'task', outcome: 'succeeded' });
893890
});
894891

895892
it('a sink that throws changes nothing about the file the caller gets', async () => {

0 commit comments

Comments
 (0)