fix: Port eval identifier validation and persona template rendering to v1 - #6806
Merged
Conversation
`LocalEvalSetsManager` and `LocalEvalSetResultsManager` interpolated the caller-supplied `app_name`, `eval_set_id` and `eval_set_result_id` straight into a filesystem path, so an identifier containing a separator or a traversal segment addressed a directory outside the app's own eval storage. They now call a new shared helper, `evaluation._path_validation .validate_path_segment`, before any path is constructed. The helper rejects empty values, null bytes, `/`, `\`, `.` and `..`. Behaviour change: these identifiers now raise `ValueError` for the values listed above. Callers that relied on a separator in `app_name` to nest eval storage under a hierarchical name are affected. Port of 7b87f91 on main.
…rs (v1) `GcsEvalSetsManager` and `GcsEvalSetResultsManager` interpolated `app_name`, `eval_set_id` and `eval_set_result_id` straight into a blob name. A separator or a traversal segment in one of those identifiers therefore composed a key addressing a different app's prefix on a shared evaluation bucket. The only guard on this branch was `_validate_id`, called from `create_eval_set` alone; every read, list and update path reached the blob-name builders unchecked, and `app_name` was never checked at all. Both managers now call `validate_path_segment` before building a blob name, the same helper the local managers use. Behaviour change: these identifiers now raise `ValueError` when empty or when they contain a null byte, `/`, `\`, `.` or `..`. A deployment using hierarchical app names for GCS-backed eval storage is affected. Port of a56f6e1 on main.
…(v1)
Both user-simulator prompt builders render nested persona strings through a
`render_string_filter`, and that filter built a fresh `jinja2.Template` from
the persona text and rendered it. A fresh `Template` uses jinja2's default
environment, so the nested render ran with no sandbox regardless of the
outer environment. A persona behaviour name such as
`{{ ''.__class__.__mro__ }}` was evaluated during prompt construction and
could walk the type hierarchy. `per_turn_user_simulator_quality_prompts.py`
was additionally building its outer environment with a plain `Environment`.
The filter now renders through the enclosing environment with
`template_env.from_string(...)`, and the per-turn builder's environment is a
`SandboxedEnvironment` like the other one. `context.get_all()` is passed
because `from_string(...).render()` takes a mapping rather than a jinja2
`Context`.
Behaviour change: a persona that relies on attribute traversal in a nested
template now raises `jinja2.exceptions.SecurityError` during prompt
construction. Supported placeholders such as `{{ stop_signal }}` render
exactly as before.
Port of 30493ba on main.
xuanyang15
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports three evaluation commits from
mainto thev1branch.Validate local eval path segments(7b87f910)evaluation/_path_validation.pyholdsvalidate_path_segment.app_name,eval_set_idandeval_set_result_idraiseValueErrorwhen empty, when they contain a null byte,/or\, or when the whole value is.or... A dot inside a value is fine:app.v2passes.app_namethat nests eval storage under a hierarchical name raises. Flatten the name; there is no opt-out.Validate path segments in the GCS eval managers(a56f6e13)Render nested persona templates through the enclosing environment(30493bae)template_env.from_string, and both outer environments areSandboxedEnvironment.{{ stop_signal }}render normally.