Missing `.to_s` when rendering a node (dropped possibily by accident)
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
Hey y'all,
I'm upgrading from Liquid v4 to v5 and encountered a subtle yet impactful breaking change that caused us a significant number of test failures. It seems that during a refactor, the call to .to_s for a node output was unintentionally (?) dropped.
If we travel back in time and look at black_body.rb from commit c2ef24, we can appreciate how it'd still explicitly call .to_s on the output of node#render unless the result was an array.
However, while refactoring to improve rendering back in #1091 the new render_to_output_buffer dropped this, maybe by accident (?). Instead, it started "appending" the result of render directly to the output buffer without stringifying it.
This causes this funny case where if your output returns a number, the << operation ends up adding a byte instead of the stringified value.
i.e.:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/liquid/block_body.rb and the render_to_output_buffer entry point described in the issue, then compare it with the historical behavior linked from commit c2ef24 and PR #1091. Reproduce rendering a node that returns a number and add a regression test; done means the rendered output is stringified rather than appended as a byte.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100