Skip to content

fix(core): validate swipe action parameters - #3069

Open
linhongyu510 wants to merge 1 commit into
web-infra-dev:mainfrom
linhongyu510:fix/swipe-param-validation
Open

fix(core): validate swipe action parameters#3069
linhongyu510 wants to merge 1 commit into
web-infra-dev:mainfrom
linhongyu510:fix/swipe-param-validation

Conversation

@linhongyu510

Copy link
Copy Markdown
Contributor

Summary

  • require swipe distance and duration to be positive finite numbers
  • require repeat to be a non-negative finite integer
  • reject end and distance when supplied together
  • require direction for distance-based swipes
  • preserve the existing repeat=0 safety cap and clarify its description
  • add focused schema and runtime regression coverage

Problem

Invalid Swipe parameters could previously produce unexpected device actions:

  • negative distance reversed the requested swipe direction
  • negative repeat silently executed zero times
  • fractional repeat could execute more times than requested
  • invalid duration values reached platform adapters
  • distance was silently ignored when end was also present

The repeat=0 description also claimed infinite execution, while the implementation intentionally capped it at 10 iterations.

Changes

Validation is applied at two boundaries:

  1. the action schema validates model-generated scalar parameters
  2. normalizeMobileSwipeParam() validates runtime and direct SDK input

Cross-field constraints remain in the runtime normalization layer so the schema stays a ZodObject and existing locator-field extraction continues to work.

Validation

  • Swipe regression suite: 20 tests passed
  • device and related planning suite: 6 files, 73 tests passed
  • Core build type-check: passed
  • Biome: 1605 files passed

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.

1 participant