Skip to content

refactor(workflow): add Jinja2 renderer abstraction for template transform#3

Open
tomerqodo wants to merge 6 commits intoaugment_full_base_refactorworkflow_add_jinja2_renderer_abstraction_for_template_transform_pr3from
augment_full_head_refactorworkflow_add_jinja2_renderer_abstraction_for_template_transform_pr3
Open

refactor(workflow): add Jinja2 renderer abstraction for template transform#3
tomerqodo wants to merge 6 commits intoaugment_full_base_refactorworkflow_add_jinja2_renderer_abstraction_for_template_transform_pr3from
augment_full_head_refactorworkflow_add_jinja2_renderer_abstraction_for_template_transform_pr3

Conversation

@tomerqodo
Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#3

laipz8200 and others added 6 commits January 25, 2026 12:04
…de and threaded it through DifyNodeFactory so TemplateTransform nodes receive the dependency by default, keeping behavior unchanged unless an override is provided. Changes are in `api/core/workflow/nodes/template_transform/template_transform_node.py` and `api/core/workflow/nodes/node_factory.py`.

**Commits**
- chore(workflow): identify TemplateTransform dependency on CodeExecutor
- feat(workflow): add CodeExecutor constructor injection to TemplateTransformNode (defaulting to current behavior)
- feat(workflow): inject CodeExecutor from DifyNodeFactory when creating TemplateTransform nodes

**Tests**
- Not run (not requested)

Next step: run `make lint` and `make type-check` if you want to validate the backend checks.
…Transform to use it, keeping CodeExecutor as the default adapter while preserving current behavior. Updates are in `api/core/workflow/nodes/template_transform/template_renderer.py`, `api/core/workflow/nodes/template_transform/template_transform_node.py`, `api/core/workflow/nodes/node_factory.py`, and `api/tests/unit_tests/core/workflow/nodes/template_transform/template_transform_node_spec.py`.

Commit-style summary:
- feat(template-transform): add Jinja2 template renderer abstraction with CodeExecutor adapter
- refactor(template-transform): use renderer in node/factory and update unit test patches

Tests not run (not requested).
…ode creation to return TemplateTransformNode directly for template-transform nodes in `api/core/workflow/nodes/node_factory.py`.

Commit-style summary:
- refactor(template-transform): derive TemplateRenderError from ValueError
- refactor(node-factory): instantiate TemplateTransformNode directly with injected renderer

Tests not run (not requested).
…ts/core/workflow/nodes/template_transform/template_transform_node_spec.py`)

chore(type-check): ran `make type-check` (basedpyright clean, 0 errors)

No errors reported.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Jan 26, 2026

🤖 Augment PR Summary

Summary: Refactors Template Transform rendering by introducing a Jinja2 renderer abstraction, making template execution easier to inject and mock.

Changes:

  • Added Jinja2TemplateRenderer protocol plus a CodeExecutorJinja2TemplateRenderer adapter.
  • Updated TemplateTransformNode to accept an optional renderer dependency and call it during _run.
  • Extended DifyNodeFactory to build Template Transform nodes with a shared renderer instance.
  • Refactored and greatly expanded unit tests to mock render_template and cover many template scenarios.

Technical Notes: Execution still flows through CodeExecutor with CodeLanguage.JINJA2, but the integration is now behind a small interface for easier testing and future renderer swaps.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

result = self._code_executor.execute_workflow_code_template(
language=CodeLanguage.JINJA2, code=template, inputs=variables
)
except CodeExecutionError as exc:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execute_workflow_code_template() can raise non-CodeExecutionError exceptions (e.g., ValueError from transform_response), which currently won’t be wrapped and may bubble up and crash node execution. Consider normalizing those failures into TemplateRenderError so TemplateTransformNode can consistently return FAILED instead of throwing.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

rendered = result.get("result")
if rendered is not None and not isinstance(rendered, str):
raise TemplateRenderError("Template render result must be a string.")
return rendered
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

render_template() is typed to return str, but this returns None when result["result"] is missing/None, which will later break len(rendered) in TemplateTransformNode._run. Consider raising TemplateRenderError when the render result is missing/None to keep the contract consistent.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants