fix: validate REME env vars before launching to prevent TypeError#37
fix: validate REME env vars before launching to prevent TypeError#37haosenwang1018 wants to merge 2 commits intomodelscope:mainfrom
Conversation
When REME_PATH or REME_SCRIPT are not set in the environment, pty_launch() passes None values to LaunchCommandWhenAbsent, which crashes with TypeError during hash computation. Add early validation with a clear error message listing which variables are missing, instead of a cryptic TypeError deep in the daemon module. Fixes modelscope#9
Summary of ChangesHello @haosenwang1018, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where the application would crash with an unhelpful Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request effectively addresses the issue where missing environment variables caused a cryptic TypeError during the launch process. By adding early validation in pty_launch, the code now provides a clear and actionable error message for all services. This is a significant improvement to the robustness and user experience of the launcher. I have suggested using RuntimeError instead of the legacy EnvironmentError to align with modern Python practices. Note that the hardcoded tag in the service launch logic (line 116) may cause log collisions for non-appworld services and should be addressed separately.
launcher.py
Outdated
| if not service_path or not service_script: | ||
| missing = [v for v in (path_var, script_var) | ||
| if not os.environ.get(v)] | ||
| raise EnvironmentError( |
There was a problem hiding this comment.
In Python 3, EnvironmentError is a legacy alias for OSError. For configuration or pre-condition errors like this, RuntimeError is generally more idiomatic as it indicates a failure to meet the requirements for execution. This change improves maintainability by following modern Python standards.
| raise EnvironmentError( | |
| raise RuntimeError( |
Problem
Running
python launcher.py --with-remewithoutREME_PATHandREME_SCRIPTin the environment crashes with a crypticTypeError: sequence item 0: expected str instance, NoneType founddeep indaemon.pyduring hash computation.Fixes #9
Fix
Add early validation in
pty_launch()that checks whether the required environment variables are set. If missing, raisesEnvironmentErrorwith a clear message listing which variables need to be defined.Changes
launcher.py: Validate{SERVICE}_PATHand{SERVICE}_SCRIPTenv vars before use