Skip to content

Commit 333eef5

Browse files
committed
fix(core): hand an untokenized api action to its handler unchanged
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jTDpMW8KaXLg1DFU6f
1 parent d7a518f commit 333eef5

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎ui/packages/core/src/actions/ActionRunner.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,12 +1687,11 @@ export class ActionRunner {
16871687
// documented `${ctx.recordId}` went out on the wire as the literal
16881688
// placeholder while a `url` target with the same token resolved. One
16891689
// substitution, one vocabulary, one encoding, whoever sends the request.
1690-
return handler(
1691-
actionType === 'api' && typeof action.target === 'string'
1692-
? { ...action, target: this.interpolateTarget(action.target, action) }
1693-
: action,
1694-
this.context,
1695-
);
1690+
// A target with no token reaches the handler as the same object.
1691+
const target = actionType === 'api' && typeof action.target === 'string'
1692+
? this.interpolateTarget(action.target, action)
1693+
: action.target;
1694+
return handler(target === action.target ? action : { ...action, target }, this.context);
16961695
}
16971696

16981697
// Built-in action execution by type.

‎ui/packages/core/src/actions/__tests__/ActionRunner.apiHandlerTarget-26722.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ describe('api targets interpolate before a registered api handler (objectstack#2
5656
expect(seen[0].method).toBe(method);
5757
});
5858

59+
it('an api target with no token reaches the handler as the same action object', async () => {
60+
const runner = new ActionRunner(RECORD_PAGE);
61+
const { seen, handler } = recordingApiHandler();
62+
runner.registerHandler('api', handler);
63+
const action: ActionDef = { type: 'api', name: 'plain', target: '/api/v1/data/gapdata_item', method: 'POST' };
64+
65+
await runner.execute(action);
66+
67+
expect(seen[0]).toBe(action);
68+
});
69+
5970
it('encodes each value the way a url target does', async () => {
6071
const context: ActionContext = { record: { id: 'a/b c' }, objectName: 'gapdata_item' };
6172
const runner = new ActionRunner(context);

0 commit comments

Comments
 (0)