Shopify / Shopify/liquid

Liquid::Template.parse(text) error in rspec after ver 5.6~

Open
#1,976 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Report
Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

only in rspec, the method has error.
works fine in application env, or rails console.

rspec result:

Failure/Error: template = Liquid::Template.parse(text.to_s)

     NoMethodError:
       undefined method `peek_byte' for #<StringScanner 0/26 @ "Hello...">
     # /usr/local/bundle/gems/liquid-5.6.4/lib/liquid/tokenizer.rb:74:in `next_token'
     # /usr/local/bundle/gems/liquid-5.6.4/lib/liquid/tokenizer.rb:65:in `shift_normal'
     # /usr/local/bundle/gems/liquid-5.6.4/lib/liquid/tokenizer.rb:57:in `tokenize'
     # /usr/local/bundle/gems/liquid-5.6.4/lib/liquid/tokenizer.rb:33:in `initialize'
     # /usr/local/bundle/gems/liquid-5.6.4/lib/liquid/parse_context.rb:45:in `new'
     # /usr/local/bundle/gems/liquid-5.6.4/lib/liquid/parse_context.rb:45:in `new_tokenizer'
     # /usr/local/bundle/gems/liquid-5.6.4/lib/liquid/template.rb:105:in `parse'
     # /usr/local/bundle/gems/liquid-5.6.4/lib/liquid/template.rb:85:in `parse'
...

downgrading to 5.5~, error has gone.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Liquid::Template.parse and the tokenizer failure at lib/liquid/tokenizer.rb:74, reproducing the reported call under RSpec with Liquid 5.6.4 and then comparing it with 5.5. Confirm that parsing the same text works outside RSpec and that the fix removes the peek_byte error without regressing parsing.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.