fix: add maxSiblingElements to prevent HTTP 413 with large dropdowns#401
Open
octo-patch wants to merge 1 commit intoalibaba:mainfrom
Open
fix: add maxSiblingElements to prevent HTTP 413 with large dropdowns#401octo-patch wants to merge 1 commit intoalibaba:mainfrom
octo-patch wants to merge 1 commit intoalibaba:mainfrom
Conversation
…ixes alibaba#348) When a dropdown with many options is open, all options are indexed as interactive elements and included in the dehydrated HTML sent to the LLM, causing HTTP 413 Payload Too Large errors. Add a maxSiblingElements option to DomConfig that limits how many same-tag children are rendered per parent node in the dehydrated output. Excess items are replaced with a summary line. The option is off by default to preserve backward compatibility.
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.
Fixes #348
Problem
When a dropdown with many options is open (e.g. a country selector with 200+ entries), all visible option elements get indexed as interactive elements and included in the dehydrated HTML sent to the LLM. This causes the LLM API to return HTTP 413: Payload Too Large.
The maintainer confirmed this in the issue comments: "听起来所有的 options 都被放在了清洗后的数据里" (it sounds like all options are being put into the cleaned data).
Solution
Add a
maxSiblingElementsoption toDomConfig(and consequentlyPageControllerConfig). When set, theflatTreeToStringfunction limits how many same-tag children are rendered per parent node. Excess items are replaced with a single summary line, e.g.:This tells the LLM there are more options available, so it can scroll or search the dropdown instead of expecting all items upfront.
The option is
undefinedby default (no limit), preserving full backward compatibility.Usage
Testing
undefinedby default: existing behavior is unchangedsimplifiedHTMLon a page with a large dropdown open and confirming the output is truncated with a descriptive summary line