-
Notifications
You must be signed in to change notification settings - Fork 1
Cache the checkout #61
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
Conversation
Pull Request Feedback 🔍
|
|
|
||
| # Start lsproxy | ||
| p = sandbox.exec("lsproxy") | ||
| sandbox = ModalSandbox(repo_url, git_token, sha, timeout, version) |
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.
Suggestion: Ensure that the ModalSandbox object is properly terminated or cleaned up in case of an exception to prevent resource leaks. [possible issue]
| sandbox = ModalSandbox(repo_url, git_token, sha, timeout, version) | |
| try: | |
| sandbox = ModalSandbox(repo_url, git_token, sha, timeout, version) | |
| except Exception as e: | |
| if sandbox: | |
| sandbox.terminate() | |
| raise e |
| client = cls(base_url=f"{sandbox.tunnel_url}/v1", auth_token=sandbox.jwt_token) | ||
|
|
||
| print("Waiting for server start up (make take a minute)...") | ||
| for attempt in range(180): |
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.
Suggestion: Consider adding a timeout or retry mechanism to the server startup loop to handle cases where the server fails to start within the expected time. [enhancement]
| for attempt in range(180): | |
| for attempt in range(180): | |
| time.sleep(1) | |
| if server_is_ready(): | |
| break | |
| else: | |
| raise TimeoutError("Server failed to start within the expected time.") |
| filtered_env = {k: v for k, v in env.items() if v is not None} | ||
|
|
||
| # subprocess.run already handles quoting | ||
| keyvalues = [f"{k}={v}" for k, v in filtered_env.items()] |
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.
Suggestion: Use shlex.quote to safely construct the keyvalues list to prevent potential shell injection vulnerabilities. [security]
| keyvalues = [f"{k}={v}" for k, v in filtered_env.items()] | |
| import shlex | |
| keyvalues = [f"{k}={shlex.quote(v)}" for k, v in filtered_env.items()] |
| result = subprocess.run( | ||
| ["modal", "secret", "create", "--force", secret_name, *keyvalues], | ||
| capture_output=True, | ||
| text=True, | ||
| ) |
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.
Suggestion: Add a timeout parameter to the subprocess.run call to prevent indefinite blocking in case of command execution issues. [possible issue]
| result = subprocess.run( | |
| ["modal", "secret", "create", "--force", secret_name, *keyvalues], | |
| capture_output=True, | |
| text=True, | |
| ) | |
| result = subprocess.run( | |
| ["modal", "secret", "create", "--force", secret_name, *keyvalues], | |
| capture_output=True, | |
| text=True, | |
| timeout=60, | |
| ) |
| {"GITHUB_IAT": git_token}, | ||
| f"gh-iat-token-{repo_id}" | ||
| ) | ||
| url_parts = repo_url.split("://") |
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.
Suggestion: Check the validity of the repo_url before using it to prevent potential errors during the git clone operation. [possible bug]
| url_parts = repo_url.split("://") | |
| if "://" not in repo_url: | |
| raise ValueError("Invalid repository URL") | |
| url_parts = repo_url.split("://") |
Description
ModalSandboxclass inlsproxy/modal.pyto encapsulate the logic for creating and managing sandboxes, including repository cloning and JWT token handling.lsproxy/client.pyto utilize theModalSandboxclass, simplifying the initialization process and removing direct dependencies onmodaland JWT token creation.create_named_modal_secretto handle secret creation with stable JSON stringification and SHA256 hashing.Changes walkthrough
client.py
Refactor client to use ModalSandbox for sandbox managementlsproxy/client.py
modaland JWT tokencreation.
ModalSandboxclass for sandbox creation andmanagement.
to
ModalSandbox.modal.py
Add ModalSandbox class for enhanced sandbox managementlsproxy/modal.py
ModalSandboxclass to encapsulate sandbox creation andmanagement.
create_named_modal_secretfunction for creating secrets withstable JSON and SHA256 hash.
within
ModalSandbox.💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.