-
Notifications
You must be signed in to change notification settings - Fork 1k
Use SandboxedEnvironment for Template #4013
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
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.
Pull Request Overview
This pull request introduces conditional usage of jinja2’s SandboxedEnvironment for template rendering based on the PF_USE_SANDBOX_FOR_JINJA environment variable, ensuring safer template execution. Key changes include:
- Updating CLI, core utilities, static web blueprint, and connection utilities to use SandboxedEnvironment when enabled.
- Wrapping template rendering in try/except blocks to capture and re-raise errors as UserErrorException.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
src/promptflow-devkit/promptflow/_cli/_pf/_init_entry_generators.py | Adds sandboxed template loading with conditional environment variable check and error handling. |
src/promptflow-core/promptflow/core/_utils.py | Updates the render function to support sandboxed templates and wraps rendering logic in a try/except block. |
src/promptflow-core/promptflow/core/_serving/v1/blueprint/static_web_blueprint.py | Implements conditional sandboxed rendering of static web templates with error capturing. |
src/promptflow-core/promptflow/_utils/connection_utils.py | Modifies connection template generation to use a sandboxed jinja2 environment, including error handling. |
Description
Please add an informative description that covers that changes made by the pull request and link all relevant issues.
All Promptflow Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines