-
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
Used a regex expression for simple URL validation and added tests #3763
Used a regex expression for simple URL validation and added tests #3763
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3763 +/- ##
==========================================
+ Coverage 62.66% 62.67% +0.01%
==========================================
Files 74 74
Lines 3426 3427 +1
Branches 504 504
==========================================
+ Hits 2147 2148 +1
Misses 1123 1123
Partials 156 156
☔ View full report in Codecov by Sentry. |
this sort of regex-based validation routine would also be useful in other places, like file name/path validation (for shell command execution) |
@ntindle BTW, there is a failing test ( ./tests/integration/test_execute_code.py::test_execute_python_file Failed: [undefined]assert 'Error: Error...directory\'")' == 'Hello udaxihhexd!\n'
- Hello udaxihhexd!
+ Error: Error while fetching server API version: 500 Server Error for http+docker://localhost/version: Internal Server Error ("b'dial unix docker.raw.sock: connect: no such file or directory'")
python_test_file = '/private/var/folders/58/jb5nf1y51b1btsjnnsn9jsdc0000gn/T/pytest-of-omrigrossman/pytest-13/test_execute_python_file0/home/users/monty/auto_gpt_workspace/tmph3oy_5_j.py'
random_string = 'udaxihhexd'
def test_execute_python_file(python_test_file: str, random_string: str):
result = sut.execute_python_file(python_test_file)
> assert result == f"Hello {random_string}!\n"
E assert 'Error: Error...directory\'")' == 'Hello udaxihhexd!\n'
E - Hello udaxihhexd!
E + Error: Error while fetching server API version: 500 Server Error for http+docker://localhost/version: Internal Server Error ("b'dial unix docker.raw.sock: connect: no such file or directory'") |
This is a mass message from the AutoGPT core team. For more details (and for infor on joining our Discord), please refer to: |
I think it maybe smarter to use a library for validation. The repository may find URL/URI/Path validation useful in other areas. |
Are we sure Regex is the way to go here? Aren’t there entire libraries for validation? |
This would at least seem like a start, maybe the OP would like to adopt the feature and extend it over time? |
@OmriGM would you consider something like this? urllib: from urllib.parse import urlparse
parsed_url = urlparse("https://www.google.com")
assert bool(parsed_url.scheme and parsed_url.netloc) Or the validators package ...
import validators
assert validators.url("http://google.com")
... We'd like to get this into 0.3.2. Please also update the branch. |
Deployment failed with the following error:
|
…gnificant-Gravitas#3763) Co-authored-by: k-boikov <[email protected]> Co-authored-by: Richard Beales <[email protected]>
Background
Changes
The expression before:
The expression after:
Also, added unit test to
tests/unit/test_url_validation.py
module, specifically tovalidate_url()
which is the main function in the moduleDocumentation
Test Plan
PR Quality Checklist