Skip to content

fix: detect position modifiers misused after find locators#669

Open
juliobrasa wants to merge 1 commit intovercel-labs:mainfrom
juliobrasa:fix/find-first-last-modifiers
Open

fix: detect position modifiers misused after find locators#669
juliobrasa wants to merge 1 commit intovercel-labs:mainfrom
juliobrasa:fix/find-first-last-modifiers

Conversation

@juliobrasa
Copy link

Summary

  • Detects when first/last/nth appears in the subaction position after a semantic locator
  • Returns a clear error message with the correct syntax instead of a confusing Zod validation error

Problem

Running find role spinbutton first fill '20' produces:

✗ Validation error: name: Expected string, received null, subaction: Invalid enum value.
Expected 'click' | 'fill' | 'check' | 'hover', received 'first'

Now it produces:

"first" cannot be used as a modifier after "role". Use it as the primary locator: find first <selector> [action] [text]

Test plan

  • cargo check passes
  • Verified error message is clear and suggests correct syntax

Fixes #364

🤖 Generated with Claude Code

When users write `find role spinbutton first fill '20'`, the `first`
keyword ends up in the subaction position causing a confusing Zod
validation error. Now the CLI detects this pattern and returns a
helpful error message explaining that first/last/nth are locator
types, not modifiers, with the correct syntax.

Fixes vercel-labs#364

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Mar 6, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

return Err(ParseError::InvalidValue {
message: format!(
"\"{}\" cannot be used as a modifier after \"{}\". \
Use it as the primary locator: find {} <selector> [action] [text]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message and usage hint are incorrect when nth is misused as a position modifier after a locator type (e.g., find role spinbutton nth).

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

find: first/last cannot be used as modifiers after role/text locators

1 participant