-
Notifications
You must be signed in to change notification settings - Fork 46.2k
Fix XMLParserBlock list object error #11517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Fix XMLParserBlock list object error #11517
Conversation
Co-authored-by: nicholas.tindle <[email protected]>
|
Cursor Agent can help with this pull request. Just |
✅ Deploy Preview for auto-gpt-docs-dev canceled.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Deploy Preview for auto-gpt-docs canceled.
|
|
Here's the code health analysis summary for commits Analysis Summary
|
|
Thank you for this well-documented PR addressing the XMLParserBlock crash issue. Your implementation of input validation looks solid and will help prevent the reported error. Before this can be merged, please complete the testing checklist. You've outlined a good test plan but haven't marked it as completed. Please run through the tests you've specified:
Once you've completed these tests, please check the corresponding box in your PR description. The code changes themselves look good, but we need confirmation that they've been properly tested. |
Need for these changes 💡
The
XMLParserBlockwas susceptible to crashing with anAttributeError: 'List' object has no attribute 'add_text'when processing malformed XML inputs, such as documents with multiple root elements or stray text outside the root. This PR introduces robust validation to prevent these crashes and provide clear, actionable error messages to users.Changes 🏗️
_validate_tokensstatic method toXMLParserBlockto perform pre-parsing validation on the token stream. This method ensures the XML input has a single root element and no text content outside of it.XMLParserBlock.runmethod to call_validate_tokensimmediately after tokenization and before passing the tokens togravitasml.Parser.test_rejects_text_outside_root, intest_blocks_dos_vulnerability.pyto verify that theXMLParserBlockcorrectly raises aValueErrorwhen encountering XML with text outside the root element.Tokenfor type hinting inxml_parser.py.Checklist 📋
For code changes:
poetry run prisma generateagainst a configured DB)./home/ubuntu/.local/bin/poetry --directory /workspace/autogpt_platform/backend run pytest backend/blocks/test/test_blocks_dos_vulnerability.py -k xmltest_rejects_text_outside_roottest passes, asserting thatValueErroris raised for invalid XML.For configuration changes:
.env.defaultis updated or already compatible with my changesdocker-compose.ymlis updated or already compatible with my changesLinear Issue: OPEN-2835