fix: allow null selector in screenshot command schema (#236)
The screenshot command was failing with 'Validation error: selector: Expected string, received null' when only a path was provided (e.g., 'agent-browser screenshot ~/Desktop/test.png'). The Rust CLI serializes None values as null in JSON, but the Zod schema only allowed undefined (via .optional()), not null. Changed selector field to use .nullish() which accepts both null and undefined. Fixes issue where screenshot command without selector fails validation.
This commit is contained in:
@@ -122,6 +122,13 @@ describe('parseCommand', () => {
|
||||
const result = parseCommand(cmd({ id: '1', action: 'screenshot', fullPage: true }));
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should parse screenshot with null selector', () => {
|
||||
const result = parseCommand(
|
||||
cmd({ id: '1', action: 'screenshot', path: 'test.png', selector: null })
|
||||
);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('cookies', () => {
|
||||
|
||||
+1
-1
@@ -693,7 +693,7 @@ const screenshotSchema = baseCommandSchema.extend({
|
||||
action: z.literal('screenshot'),
|
||||
path: z.string().nullable().optional(),
|
||||
fullPage: z.boolean().optional(),
|
||||
selector: z.string().min(1).optional(),
|
||||
selector: z.string().min(1).nullish(),
|
||||
format: z.enum(['png', 'jpeg']).optional(),
|
||||
quality: z.number().min(0).max(100).optional(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user