fix(SKY-12019): guard clear/fill actions from targeting non-editable elements#7164
Draft
AronPerez wants to merge 1 commit into
Draft
Conversation
…elements The planner occasionally selected a non-editable element (e.g. an hCaptcha iframe) as the target for an INPUT_TEXT action. Execution then attempted Locator.clear/fill on the iframe, failing the step. Add SkyvernElement.supports_text_input() (input/textarea/select, Playwright editable, or contenteditable) and reject INPUT_TEXT up front with InvalidElementForTextInput when the target isn't editable, before any clear/fill attempt. Generated with [Linear](https://linear.app/skyvern/issue/SKY-12019/guard-clearfill-actions-from-targeting-hcaptcha-iframes#agent-session-5326e368) Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The action planner occasionally selects a non-editable element — such as an hCaptcha iframe — as the target for an
INPUT_TEXTaction. Execution then attemptedLocator.clear/Locator.fillon that iframe, which failed mid-step.This adds an editable-element guard so clear/fill only target valid text inputs:
SkyvernElement.supports_text_input()— true forinput/textarea/select, Playwright-editable elements, orcontenteditableelements.handle_input_text_actionnow rejects the action up front withInvalidElementForTextInputwhen the target isn't editable, before any clear/fill attempt (so an iframe target fails cleanly instead of erroring insideLocator.clear).The existing non-editable fill path only fired for
contenteditableelements Playwright doesn't report as editable, which the new guard still permits; truly non-editable targets (iframes, plain divs) would have thrown from Playwright anyway and now get a clear error instead.How Has This Been Tested?
Added
tests/unit/test_input_text_iframe_guard.py:supports_text_input()unit cases: iframe → rejected; input/textarea/select and editable/contenteditable → accepted;contenteditable="false"→ rejected.INPUT_TEXTaction targeting an iframe returnsActionFailure(InvalidElementForTextInput)and never callsinput_clear/input_fill.(pytest isn't installed in this sandbox, so the suite wasn't executed here — CI should run it.)