liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Missing `.to_s` when rendering a node (dropped possibily by accident)

Open Andy9822 opened this issue 1 year ago • 0 comments

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. Image

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.

Image

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.:

Image

Andy9822 avatar Jan 14 '25 22:01 Andy9822