[PR #108] [MERGED] Lazily render variables #44

Closed
opened 2025-12-29 07:19:02 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mountain-loop/yaak/pull/108
Author: @gschier
Created: 9/24/2024
Status: Merged
Merged: 9/24/2024
Merged by: @gschier

Base: masterHead: lazy-variable-rendering


📝 Commits (1)

📊 Changes

2 files changed (+25 additions, -29 deletions)

View changed files

📝 src-tauri/src/render.rs (+5 -28)
📝 src-tauri/yaak_templates/src/renderer.rs (+20 -1)

📄 Description

This PR restructures how environment variable values are rendered during the render pipeline, to eliminate the chances of accidental infinite recursion.

Before: The environment was recursively rendered and passed into another render call to render this actual thing (eg. request). This meant that ALL variables were rendered, even when not used. This also meant that template functions (eg. response()) that called render again could potentially enter an infinite render loop.

After:: Now, an environment variable is only rendered if it was referenced in the thing (eg. request). If a variable was referenced, its value is looked up and rendered again. This means the only way to enter infinite recursion is if a variable tries to render itself. This would be user error, however (we should also add detection for this case to warn the user).

Fixes #107


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mountain-loop/yaak/pull/108 **Author:** [@gschier](https://github.com/gschier) **Created:** 9/24/2024 **Status:** ✅ Merged **Merged:** 9/24/2024 **Merged by:** [@gschier](https://github.com/gschier) **Base:** `master` ← **Head:** `lazy-variable-rendering` --- ### 📝 Commits (1) - [`4ccd4d8`](https://github.com/mountain-loop/yaak/commit/4ccd4d8f6be0c6e1a79ac7c906bcb092f8f00ab0) Lazily render variables (Fixes #107) ### 📊 Changes **2 files changed** (+25 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/render.rs` (+5 -28) 📝 `src-tauri/yaak_templates/src/renderer.rs` (+20 -1) </details> ### 📄 Description This PR restructures how environment variable values are rendered during the render pipeline, to eliminate the chances of accidental infinite recursion. **Before:** The environment was recursively rendered and passed into another render call to render this actual thing (eg. request). This meant that ALL variables were rendered, even when not used. This also meant that template functions (eg. `response()`) that called render again could potentially enter an infinite render loop. **After::** Now, an environment variable is only rendered if it was referenced in the thing (eg. request). If a variable was referenced, its value is looked up and rendered again. This means the only way to enter infinite recursion is if a variable tries to render itself. This would be user error, however (we should also add detection for this case to warn the user). Fixes #107 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 07:19:02 +01:00
adam closed this issue 2025-12-29 07:19:02 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/yaak#44