Shopify / Shopify/liquid

Additional info needed for include error message

Open
#1,295 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

When include is used within a snippet that has been added with a render tag we see this message displayed:

Liquid error (outer-snippet-name line X): include usage is not allowed in this context

However, the error message does not display the name of the offending snippet, which would be helpful for both merchants and partners who are trying to troubleshoot. This error is often caused by apps injecting include tags and it can prove very difficult to identify which app is causing the error - any surfaced information (such as name of the snippet using include can be extremely valuable in identifying the issue.

Suggested change could be:

Liquid error (image-style line 20): include 'test.liquid' is not allowed in this context

Currently this generic message is coming from https://github.com/Shopify/liquid/blob/master/lib/liquid/tag/disableable.rb#L16

using the translation from here: https://github.com/Shopify/liquid/blob/master/lib/liquid/locales/en.yml#L29

If possible we could define Liquid::Include#disabled_error more specifically for the include tag to provide a better error message.

CC: @Marcus-Seoighe @dylanahsmith

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 lib/liquid/tag/disableable.rb at the reported error and the English translation in lib/liquid/locales/en.yml; then inspect Liquid::Include for its disabled-error handling. Done means the include error identifies the offending snippet or include target while preserving the existing context and line information.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.