{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/liquid/pulls/comments/51482753","id":51482753,"diff_hunk":"@@ -54,6 +54,8 @@ def evaluate(context)\n         elsif @command_flags & (1 << i) != 0 && object.respond_to?(key)\n           object = object.send(key).to_liquid\n \n+        elsif context.strict_variables\n+          raise Liquid::UndefinedVariable, \"undefined variable #{key} in #{object}\"","path":"lib/liquid/variable_lookup.rb","position":5,"original_position":5,"commit_id":"6b5540200fedb44900cb770b9da4af9b56a71bf9","original_commit_id":"6b5540200fedb44900cb770b9da4af9b56a71bf9","user":{"login":"fw42","id":2072686,"avatar_url":"https://avatars.githubusercontent.com/u/2072686?v=3","gravatar_id":"","url":"https://api.github.com/users/fw42","html_url":"https://github.com/fw42","followers_url":"https://api.github.com/users/fw42/followers","following_url":"https://api.github.com/users/fw42/following{/other_user}","gists_url":"https://api.github.com/users/fw42/gists{/gist_id}","starred_url":"https://api.github.com/users/fw42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fw42/subscriptions","organizations_url":"https://api.github.com/users/fw42/orgs","repos_url":"https://api.github.com/users/fw42/repos","events_url":"https://api.github.com/users/fw42/events{/privacy}","received_events_url":"https://api.github.com/users/fw42/received_events","type":"User","site_admin":false},"body":"I'm still worried about including `#{object}` in the string. I don't see the benefit, but I do see potential leaks.","created_at":"2016-02-01T21:23:35Z","updated_at":"2016-02-01T21:23:35Z","html_url":"https://github.com/Shopify/liquid/pull/691#discussion_r51482753","pull_request_url":"https://api.github.com/repos/Shopify/liquid/pulls/691","_links":{"self":{"href":"https://api.github.com/repos/Shopify/liquid/pulls/comments/51482753"},"html":{"href":"https://github.com/Shopify/liquid/pull/691#discussion_r51482753"},"pull_request":{"href":"https://api.github.com/repos/Shopify/liquid/pulls/691"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/liquid/pulls/691","id":57683610,"html_url":"https://github.com/Shopify/liquid/pull/691","diff_url":"https://github.com/Shopify/liquid/pull/691.diff","patch_url":"https://github.com/Shopify/liquid/pull/691.patch","issue_url":"https://api.github.com/repos/Shopify/liquid/issues/691","number":691,"state":"open","locked":false,"title":"Detect undefined variables or filters","user":{"login":"apeckham","id":14110,"avatar_url":"https://avatars.githubusercontent.com/u/14110?v=3","gravatar_id":"","url":"https://api.github.com/users/apeckham","html_url":"https://github.com/apeckham","followers_url":"https://api.github.com/users/apeckham/followers","following_url":"https://api.github.com/users/apeckham/following{/other_user}","gists_url":"https://api.github.com/users/apeckham/gists{/gist_id}","starred_url":"https://api.github.com/users/apeckham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apeckham/subscriptions","organizations_url":"https://api.github.com/users/apeckham/orgs","repos_url":"https://api.github.com/users/apeckham/repos","events_url":"https://api.github.com/users/apeckham/events{/privacy}","received_events_url":"https://api.github.com/users/apeckham/received_events","type":"User","site_admin":false},"body":"This adds `strict_variables` and `strict_filters` options to render. When true, `render` collects a list of undefined variables/filters in #errors, and `render!` raises when an undefined variable/filter is used.\r\n\r\nExample:\r\n\r\n```ruby\r\ntemplate = Liquid::Template.parse(\"{{x}} {{y}} {{z.a}} {{z.b}}\")\r\ntemplate.render({ 'x' => 1, 'z' => { 'a' => 2 } }, { strict_variables: true })\r\ntemplate.errors\r\n#=> [#<Liquid::MissingVariable: Liquid error: missing variable y>, #<Liquid::MissingVariable: Liquid error: missing variable b in {\"a\"=>2}>]\r\n```\r\n\r\nThis lets us write unit tests for our templates. Related:\r\n- #685 Get all variables used in a template\r\n- #490 Fail on nonexistent variable dereferencing\r\n- #422 Invalid filters are ignored without warning\r\n\r\nThanks @Jeiwan for working on this.\r\n\r\nThe loop over [global_filter, exception_handler, strict_variables, strict_filters] in template.rb is to fix a Rubocop cyclomatic complexity error.\r\n\r\nTests included. Will you consider merging? Happy to make changes.","created_at":"2016-01-29T18:22:38Z","updated_at":"2016-02-01T21:23:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"56d17a4e099c419d15303dfb5bdc462458e9b8ac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/liquid/pulls/691/commits","review_comments_url":"https://api.github.com/repos/Shopify/liquid/pulls/691/comments","review_comment_url":"https://api.github.com/repos/Shopify/liquid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/liquid/issues/691/comments","statuses_url":"https://api.github.com/repos/Shopify/liquid/statuses/6b5540200fedb44900cb770b9da4af9b56a71bf9","head":{"label":"urbandictionary:missing_variables_and_filters","ref":"missing_variables_and_filters","sha":"6b5540200fedb44900cb770b9da4af9b56a71bf9","user":{"login":"urbandictionary","id":80348,"avatar_url":"https://avatars.githubusercontent.com/u/80348?v=3","gravatar_id":"","url":"https://api.github.com/users/urbandictionary","html_url":"https://github.com/urbandictionary","followers_url":"https://api.github.com/users/urbandictionary/followers","following_url":"https://api.github.com/users/urbandictionary/following{/other_user}","gists_url":"https://api.github.com/users/urbandictionary/gists{/gist_id}","starred_url":"https://api.github.com/users/urbandictionary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urbandictionary/subscriptions","organizations_url":"https://api.github.com/users/urbandictionary/orgs","repos_url":"https://api.github.com/users/urbandictionary/repos","events_url":"https://api.github.com/users/urbandictionary/events{/privacy}","received_events_url":"https://api.github.com/users/urbandictionary/received_events","type":"Organization","site_admin":false},"repo":{"id":50680880,"name":"liquid","full_name":"urbandictionary/liquid","owner":{"login":"urbandictionary","id":80348,"avatar_url":"https://avatars.githubusercontent.com/u/80348?v=3","gravatar_id":"","url":"https://api.github.com/users/urbandictionary","html_url":"https://github.com/urbandictionary","followers_url":"https://api.github.com/users/urbandictionary/followers","following_url":"https://api.github.com/users/urbandictionary/following{/other_user}","gists_url":"https://api.github.com/users/urbandictionary/gists{/gist_id}","starred_url":"https://api.github.com/users/urbandictionary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urbandictionary/subscriptions","organizations_url":"https://api.github.com/users/urbandictionary/orgs","repos_url":"https://api.github.com/users/urbandictionary/repos","events_url":"https://api.github.com/users/urbandictionary/events{/privacy}","received_events_url":"https://api.github.com/users/urbandictionary/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/urbandictionary/liquid","description":"Liquid markup language. Safe, customer facing template language for flexible web apps. ","fork":true,"url":"https://api.github.com/repos/urbandictionary/liquid","forks_url":"https://api.github.com/repos/urbandictionary/liquid/forks","keys_url":"https://api.github.com/repos/urbandictionary/liquid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/urbandictionary/liquid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/urbandictionary/liquid/teams","hooks_url":"https://api.github.com/repos/urbandictionary/liquid/hooks","issue_events_url":"https://api.github.com/repos/urbandictionary/liquid/issues/events{/number}","events_url":"https://api.github.com/repos/urbandictionary/liquid/events","assignees_url":"https://api.github.com/repos/urbandictionary/liquid/assignees{/user}","branches_url":"https://api.github.com/repos/urbandictionary/liquid/branches{/branch}","tags_url":"https://api.github.com/repos/urbandictionary/liquid/tags","blobs_url":"https://api.github.com/repos/urbandictionary/liquid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/urbandictionary/liquid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/urbandictionary/liquid/git/refs{/sha}","trees_url":"https://api.github.com/repos/urbandictionary/liquid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/urbandictionary/liquid/statuses/{sha}","languages_url":"https://api.github.com/repos/urbandictionary/liquid/languages","stargazers_url":"https://api.github.com/repos/urbandictionary/liquid/stargazers","contributors_url":"https://api.github.com/repos/urbandictionary/liquid/contributors","subscribers_url":"https://api.github.com/repos/urbandictionary/liquid/subscribers","subscription_url":"https://api.github.com/repos/urbandictionary/liquid/subscription","commits_url":"https://api.github.com/repos/urbandictionary/liquid/commits{/sha}","git_commits_url":"https://api.github.com/repos/urbandictionary/liquid/git/commits{/sha}","comments_url":"https://api.github.com/repos/urbandictionary/liquid/comments{/number}","issue_comment_url":"https://api.github.com/repos/urbandictionary/liquid/issues/comments{/number}","contents_url":"https://api.github.com/repos/urbandictionary/liquid/contents/{+path}","compare_url":"https://api.github.com/repos/urbandictionary/liquid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/urbandictionary/liquid/merges","archive_url":"https://api.github.com/repos/urbandictionary/liquid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/urbandictionary/liquid/downloads","issues_url":"https://api.github.com/repos/urbandictionary/liquid/issues{/number}","pulls_url":"https://api.github.com/repos/urbandictionary/liquid/pulls{/number}","milestones_url":"https://api.github.com/repos/urbandictionary/liquid/milestones{/number}","notifications_url":"https://api.github.com/repos/urbandictionary/liquid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/urbandictionary/liquid/labels{/name}","releases_url":"https://api.github.com/repos/urbandictionary/liquid/releases{/id}","deployments_url":"https://api.github.com/repos/urbandictionary/liquid/deployments","created_at":"2016-01-29T18:05:05Z","updated_at":"2016-01-29T18:05:06Z","pushed_at":"2016-02-01T03:47:45Z","git_url":"git://github.com/urbandictionary/liquid.git","ssh_url":"git@github.com:urbandictionary/liquid.git","clone_url":"https://github.com/urbandictionary/liquid.git","svn_url":"https://github.com/urbandictionary/liquid","homepage":"http://liquidmarkup.org/","size":4009,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"08de6ed2c518b11e691ef9d35ecff054683bf7b7","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":15435,"name":"liquid","full_name":"Shopify/liquid","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/liquid","description":"Liquid markup language. Safe, customer facing template language for flexible web apps. ","fork":false,"url":"https://api.github.com/repos/Shopify/liquid","forks_url":"https://api.github.com/repos/Shopify/liquid/forks","keys_url":"https://api.github.com/repos/Shopify/liquid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/liquid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/liquid/teams","hooks_url":"https://api.github.com/repos/Shopify/liquid/hooks","issue_events_url":"https://api.github.com/repos/Shopify/liquid/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/liquid/events","assignees_url":"https://api.github.com/repos/Shopify/liquid/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/liquid/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/liquid/tags","blobs_url":"https://api.github.com/repos/Shopify/liquid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/liquid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/liquid/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/liquid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/liquid/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/liquid/languages","stargazers_url":"https://api.github.com/repos/Shopify/liquid/stargazers","contributors_url":"https://api.github.com/repos/Shopify/liquid/contributors","subscribers_url":"https://api.github.com/repos/Shopify/liquid/subscribers","subscription_url":"https://api.github.com/repos/Shopify/liquid/subscription","commits_url":"https://api.github.com/repos/Shopify/liquid/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/liquid/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/liquid/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/liquid/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/liquid/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/liquid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/liquid/merges","archive_url":"https://api.github.com/repos/Shopify/liquid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/liquid/downloads","issues_url":"https://api.github.com/repos/Shopify/liquid/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/liquid/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/liquid/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/liquid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/liquid/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/liquid/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/liquid/deployments","created_at":"2008-05-08T15:27:26Z","updated_at":"2016-02-01T20:58:25Z","pushed_at":"2016-02-01T18:14:42Z","git_url":"git://github.com/Shopify/liquid.git","ssh_url":"git@github.com:Shopify/liquid.git","clone_url":"https://github.com/Shopify/liquid.git","svn_url":"https://github.com/Shopify/liquid","homepage":"http://liquidmarkup.org/","size":4751,"stargazers_count":4069,"watchers_count":4069,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":548,"mirror_url":null,"open_issues_count":39,"forks":548,"open_issues":39,"watchers":4069,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/liquid/pulls/691"},"html":{"href":"https://github.com/Shopify/liquid/pull/691"},"issue":{"href":"https://api.github.com/repos/Shopify/liquid/issues/691"},"comments":{"href":"https://api.github.com/repos/Shopify/liquid/issues/691/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/liquid/pulls/691/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/liquid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/liquid/pulls/691/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/liquid/statuses/6b5540200fedb44900cb770b9da4af9b56a71bf9"}}}}