fix(cua): label a top-level request issue as arguments
A key outside method and params reported an empty field name; it now reads arguments: Unrecognized key, matching how other issues name their field. Refs #7869
This commit is contained in:
1 parent
4ad94b0445
commit
cfa565e1bb
2 files changed
+10
-1
No files matched your search
@@ -626,6 +626,15 @@ it('names the missing field of a request that matches none of its accepted forms
|
||||
expect(native.request).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('names an unknown top-level request key', async () => {
|
||||
const f = await setup()
|
||||
const result = await executeToolFixture(f.ctx, {
|
||||
agent: f.handle.agent, signal: new AbortController().signal, callId: ToolCallId('extra-key'), name: 'cua',
|
||||
arguments: { method: 'listApps', params: {}, extra: 1 },
|
||||
})
|
||||
expect(result.content).toEqual([{ type: 'text', text: 'Error: invalid arguments: arguments: Unrecognized key: "extra"' }])
|
||||
})
|
||||
|
||||
it('rejects malformed and unowned operations before acquiring a helper', async () => {
|
||||
const f = await setup()
|
||||
const malformed = await f.execute('screenshot', { pid: 9, windowId: '7' })
|
||||
|
||||
@@ -102,7 +102,7 @@ function executionAgent(execution: Readonly<ToolExecution>): Agent {
|
||||
*/
|
||||
function requestViolation(issue: z.core.$ZodIssue, base: readonly PropertyKey[] = []): string {
|
||||
const path = [...base, ...issue.path]
|
||||
const field = path.map(String).join('.')
|
||||
const field = path.length > 0 ? path.map(String).join('.') : 'arguments'
|
||||
if (issue.code !== 'invalid_union' || issue.errors.length === 0) return `${field}: ${issue.message}`
|
||||
const forms = issue.errors.map(form => `(${form.map(nested => requestViolation(nested, path)).join('; ')})`)
|
||||
return `${field}: matches none of the accepted forms: ${forms.join(' or ')}`
|
||||
|
||||
Reference in new issue
Block a user