-
Notifications
You must be signed in to change notification settings - Fork 44.6k
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
Move path argument sanitization for commands to a decorator #4918
Move path argument sanitization for commands to a decorator #4918
Conversation
✅ Deploy Preview for auto-gpt-docs canceled.
|
269ea1a
to
c6d0c80
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #4918 +/- ##
==========================================
+ Coverage 50.52% 50.87% +0.35%
==========================================
Files 118 117 -1
Lines 4843 4904 +61
Branches 643 660 +17
==========================================
+ Hits 2447 2495 +48
- Misses 2215 2224 +9
- Partials 181 185 +4
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use functools.wraps
in the decorator to preserve the metadata attributes of the function your decorating.
93208fb
to
ac3bf52
Compare
Co-authored-by: James Collins <[email protected]>
ac3bf52
to
3725730
Compare
You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged. |
…ant-Gravitas#4918) * Move path argument sanitization for commands to a decorator * Fix tests * Add `@functools.wraps` to `@sanitize_path_arg` decorator Co-authored-by: James Collins <[email protected]> --------- Co-authored-by: James Collins <[email protected]>
…ant-Gravitas#4918) * Move path argument sanitization for commands to a decorator * Fix tests * Add `@functools.wraps` to `@sanitize_path_arg` decorator Co-authored-by: James Collins <[email protected]> --------- Co-authored-by: James Collins <[email protected]>
Background
Part of #4799
We want to sanitize path arguments from commands before using them, to prevent workspace excursions. A decorator makes it easier to tack a sanitizer on any argument, instead of requiring that an argument has a specific name like
filename
.Changes
sanitize_path_arg
decoratorExample:
Agent._resolve_pathlike_command_args()
Documentation
x
Test Plan
CI
PR Quality Checklist