{"action":"created","comment":{"url":"https://api.github.com/repos/influxdata/flux/pulls/comments/244801572","pull_request_review_id":188761783,"id":244801572,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDgwMTU3Mg==","diff_hunk":"@@ -0,0 +1,121 @@\n+package ast\n+\n+import (\n+\t\"strconv\"\n+\t\"strings\"\n+)\n+\n+// GetErrors will collect all of the errors from the construction of the AST.\n+// If there were no errors, this will return nil. If the limit is set to\n+// positive number, it will limit the number of errors to the given number. If\n+// it is set to a negative number, it will return the last N errors. A value of\n+// zero will return all errors.\n+func GetErrors(root Node, limit int) []error {\n+\tv := errorVisitor{limit: limit}\n+\tWalk(&v, root)\n+\tif limit < 0 && len(v.errs) > -limit {\n+\t\tsz := -limit\n+\t\terrs := make([]error, 0, sz)\n+\t\tfor i := len(v.errs) - sz; i < len(v.errs); i++ {\n+\t\t\terrs = append(errs, v.errs[i])\n+\t\t}\n+\t\treturn errs\n+\t}\n+\treturn v.errs\n+}\n+\n+// errorDetail contains the details of the error. Err is the error itself while\n+// Detail is the detailed information about the error.\n+type errorDetail struct {\n+\tErr    string\n+\tDetail string\n+}\n+\n+func (e errorDetail) Error() string {\n+\tvar sb strings.Builder\n+\tsb.WriteString(e.Err)\n+\tif e.Detail != \"\" {\n+\t\tsb.WriteString(\": \")\n+\t\tsb.WriteString(e.Detail)\n+\t}\n+\treturn sb.String()\n+}\n+\n+// Error is an error within the AST. It contains the information about\n+// where the error happened along with the underlying cause.\n+type Error struct {\n+\tloc   SourceLocation\n+\tcause errorDetail\n+}\n+\n+func (e *Error) Error() string {\n+\tvar sb strings.Builder\n+\tsb.WriteString(e.cause.Err)\n+\tif e.loc.Start.Line > 0 {\n+\t\tif sb.Len() > 0 {\n+\t\t\tsb.WriteString(\":\")\n+\t\t}\n+\t\tsb.WriteString(strconv.FormatInt(int64(e.loc.Start.Line), 10))\n+\t}\n+\tif e.loc.Start.Column > 0 {\n+\t\tif sb.Len() > 0 {\n+\t\t\tsb.WriteString(\":\")\n+\t\t}\n+\t\tsb.WriteString(strconv.FormatInt(int64(e.loc.Start.Column), 10))\n+\t}\n+\tif e.cause.Detail != \"\" {\n+\t\tif sb.Len() > 0 {\n+\t\t\tsb.WriteString(\": \")\n+\t\t}\n+\t\tsb.WriteString(e.cause.Detail)\n+\t}\n+\treturn sb.String()\n+}\n+\n+func (e *Error) Location() SourceLocation {\n+\treturn e.loc\n+}\n+\n+func (e *Error) Cause() error {\n+\treturn e.cause\n+}\n+\n+type errorVisitor struct {\n+\terrs  []error\n+\tlimit int\n+}\n+\n+func (ev *errorVisitor) Visit(n Node) Visitor {\n+\tif !ev.more() {\n+\t\treturn nil\n+\t}\n+\n+\t// TODO(jsternberg): Fill in the details for how we retrieve errors.\n+\tswitch n := n.(type) {\n+\tcase *BadStatement:","path":"ast/errors.go","position":95,"original_position":95,"commit_id":"ffc9df2824ff5342a76533943decb86a88086b48","original_commit_id":"ffc9df2824ff5342a76533943decb86a88086b48","user":{"login":"nathanielc","id":3771906,"node_id":"MDQ6VXNlcjM3NzE5MDY=","avatar_url":"https://avatars3.githubusercontent.com/u/3771906?v=4","gravatar_id":"","url":"https://api.github.com/users/nathanielc","html_url":"https://github.com/nathanielc","followers_url":"https://api.github.com/users/nathanielc/followers","following_url":"https://api.github.com/users/nathanielc/following{/other_user}","gists_url":"https://api.github.com/users/nathanielc/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielc/subscriptions","organizations_url":"https://api.github.com/users/nathanielc/orgs","repos_url":"https://api.github.com/users/nathanielc/repos","events_url":"https://api.github.com/users/nathanielc/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielc/received_events","type":"User","site_admin":false},"body":"What is the plan for how to encode errors into the AST? This is the most important question to me.\r\n\r\nAlso remember that the AST needs to be able to serialize to JSON, which includes its errors. So whatever mechanism we choose needs to easily marshal/unmarshal to JSON.","created_at":"2019-01-02T17:42:10Z","updated_at":"2019-01-02T17:45:09Z","html_url":"https://github.com/influxdata/flux/pull/288#discussion_r244801572","pull_request_url":"https://api.github.com/repos/influxdata/flux/pulls/288","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/influxdata/flux/pulls/comments/244801572"},"html":{"href":"https://github.com/influxdata/flux/pull/288#discussion_r244801572"},"pull_request":{"href":"https://api.github.com/repos/influxdata/flux/pulls/288"}}},"pull_request":{"url":"https://api.github.com/repos/influxdata/flux/pulls/288","id":231270707,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxMjcwNzA3","html_url":"https://github.com/influxdata/flux/pull/288","diff_url":"https://github.com/influxdata/flux/pull/288.diff","patch_url":"https://github.com/influxdata/flux/pull/288.patch","issue_url":"https://api.github.com/repos/influxdata/flux/issues/288","number":288,"state":"open","locked":false,"title":"feat(parser): add a method for retrieving errors within the flux AST","user":{"login":"jsternberg","id":1212129,"node_id":"MDQ6VXNlcjEyMTIxMjk=","avatar_url":"https://avatars2.githubusercontent.com/u/1212129?v=4","gravatar_id":"","url":"https://api.github.com/users/jsternberg","html_url":"https://github.com/jsternberg","followers_url":"https://api.github.com/users/jsternberg/followers","following_url":"https://api.github.com/users/jsternberg/following{/other_user}","gists_url":"https://api.github.com/users/jsternberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jsternberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsternberg/subscriptions","organizations_url":"https://api.github.com/users/jsternberg/orgs","repos_url":"https://api.github.com/users/jsternberg/repos","events_url":"https://api.github.com/users/jsternberg/events{/privacy}","received_events_url":"https://api.github.com/users/jsternberg/received_events","type":"User","site_admin":false},"body":"The `GetErrors` method will traverse the AST and find any nodes that\nimplement the `error` interface. It will then add them to the list of\nerrors that were added while constructing the AST and these nodes should\nalso have information about where the error happened.\n\nThis also includes a way to limit the number of errors so that we can\nimplement a functionality to only print the first error (might be useful\nfor chronograf) or limit the command line output to the first 10 errors. If\na value of zero or lower is given, it will collect all errors.","created_at":"2018-11-15T17:10:58Z","updated_at":"2019-01-02T17:45:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5557435d3caba5f4e722935179cd282a766bc886","assignee":{"login":"nathanielc","id":3771906,"node_id":"MDQ6VXNlcjM3NzE5MDY=","avatar_url":"https://avatars3.githubusercontent.com/u/3771906?v=4","gravatar_id":"","url":"https://api.github.com/users/nathanielc","html_url":"https://github.com/nathanielc","followers_url":"https://api.github.com/users/nathanielc/followers","following_url":"https://api.github.com/users/nathanielc/following{/other_user}","gists_url":"https://api.github.com/users/nathanielc/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielc/subscriptions","organizations_url":"https://api.github.com/users/nathanielc/orgs","repos_url":"https://api.github.com/users/nathanielc/repos","events_url":"https://api.github.com/users/nathanielc/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielc/received_events","type":"User","site_admin":false},"assignees":[{"login":"nathanielc","id":3771906,"node_id":"MDQ6VXNlcjM3NzE5MDY=","avatar_url":"https://avatars3.githubusercontent.com/u/3771906?v=4","gravatar_id":"","url":"https://api.github.com/users/nathanielc","html_url":"https://github.com/nathanielc","followers_url":"https://api.github.com/users/nathanielc/followers","following_url":"https://api.github.com/users/nathanielc/following{/other_user}","gists_url":"https://api.github.com/users/nathanielc/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanielc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanielc/subscriptions","organizations_url":"https://api.github.com/users/nathanielc/orgs","repos_url":"https://api.github.com/users/nathanielc/repos","events_url":"https://api.github.com/users/nathanielc/events{/privacy}","received_events_url":"https://api.github.com/users/nathanielc/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/influxdata/flux/pulls/288/commits","review_comments_url":"https://api.github.com/repos/influxdata/flux/pulls/288/comments","review_comment_url":"https://api.github.com/repos/influxdata/flux/pulls/comments{/number}","comments_url":"https://api.github.com/repos/influxdata/flux/issues/288/comments","statuses_url":"https://api.github.com/repos/influxdata/flux/statuses/ffc9df2824ff5342a76533943decb86a88086b48","head":{"label":"influxdata:js-parser-get-errors","ref":"js-parser-get-errors","sha":"ffc9df2824ff5342a76533943decb86a88086b48","user":{"login":"influxdata","id":5713248,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MTMyNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":137362393,"node_id":"MDEwOlJlcG9zaXRvcnkxMzczNjIzOTM=","name":"flux","full_name":"influxdata/flux","private":false,"owner":{"login":"influxdata","id":5713248,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MTMyNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/influxdata/flux","description":"Flux is a lightweight scripting language for querying databases (like InfluxDB) and working with data. It's part of InfluxDB 1.7 and 2.0, but can be run independently of those.","fork":false,"url":"https://api.github.com/repos/influxdata/flux","forks_url":"https://api.github.com/repos/influxdata/flux/forks","keys_url":"https://api.github.com/repos/influxdata/flux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/flux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/flux/teams","hooks_url":"https://api.github.com/repos/influxdata/flux/hooks","issue_events_url":"https://api.github.com/repos/influxdata/flux/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/flux/events","assignees_url":"https://api.github.com/repos/influxdata/flux/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/flux/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/flux/tags","blobs_url":"https://api.github.com/repos/influxdata/flux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/flux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/flux/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/flux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/flux/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/flux/languages","stargazers_url":"https://api.github.com/repos/influxdata/flux/stargazers","contributors_url":"https://api.github.com/repos/influxdata/flux/contributors","subscribers_url":"https://api.github.com/repos/influxdata/flux/subscribers","subscription_url":"https://api.github.com/repos/influxdata/flux/subscription","commits_url":"https://api.github.com/repos/influxdata/flux/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/flux/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/flux/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/flux/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/flux/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/flux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/flux/merges","archive_url":"https://api.github.com/repos/influxdata/flux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/flux/downloads","issues_url":"https://api.github.com/repos/influxdata/flux/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/flux/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/flux/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/flux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/flux/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/flux/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/flux/deployments","created_at":"2018-06-14T13:32:57Z","updated_at":"2019-01-02T17:19:28Z","pushed_at":"2019-01-02T17:42:50Z","git_url":"git://github.com/influxdata/flux.git","ssh_url":"git@github.com:influxdata/flux.git","clone_url":"https://github.com/influxdata/flux.git","svn_url":"https://github.com/influxdata/flux","homepage":"https://influxdata.com","size":2847,"stargazers_count":65,"watchers_count":65,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":237,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":5,"open_issues":237,"watchers":65,"default_branch":"master"}},"base":{"label":"influxdata:master","ref":"master","sha":"ab71bb1423a186577424b011b5566a608f19fe89","user":{"login":"influxdata","id":5713248,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MTMyNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"repo":{"id":137362393,"node_id":"MDEwOlJlcG9zaXRvcnkxMzczNjIzOTM=","name":"flux","full_name":"influxdata/flux","private":false,"owner":{"login":"influxdata","id":5713248,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MTMyNDg=","avatar_url":"https://avatars2.githubusercontent.com/u/5713248?v=4","gravatar_id":"","url":"https://api.github.com/users/influxdata","html_url":"https://github.com/influxdata","followers_url":"https://api.github.com/users/influxdata/followers","following_url":"https://api.github.com/users/influxdata/following{/other_user}","gists_url":"https://api.github.com/users/influxdata/gists{/gist_id}","starred_url":"https://api.github.com/users/influxdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/influxdata/subscriptions","organizations_url":"https://api.github.com/users/influxdata/orgs","repos_url":"https://api.github.com/users/influxdata/repos","events_url":"https://api.github.com/users/influxdata/events{/privacy}","received_events_url":"https://api.github.com/users/influxdata/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/influxdata/flux","description":"Flux is a lightweight scripting language for querying databases (like InfluxDB) and working with data. It's part of InfluxDB 1.7 and 2.0, but can be run independently of those.","fork":false,"url":"https://api.github.com/repos/influxdata/flux","forks_url":"https://api.github.com/repos/influxdata/flux/forks","keys_url":"https://api.github.com/repos/influxdata/flux/keys{/key_id}","collaborators_url":"https://api.github.com/repos/influxdata/flux/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/influxdata/flux/teams","hooks_url":"https://api.github.com/repos/influxdata/flux/hooks","issue_events_url":"https://api.github.com/repos/influxdata/flux/issues/events{/number}","events_url":"https://api.github.com/repos/influxdata/flux/events","assignees_url":"https://api.github.com/repos/influxdata/flux/assignees{/user}","branches_url":"https://api.github.com/repos/influxdata/flux/branches{/branch}","tags_url":"https://api.github.com/repos/influxdata/flux/tags","blobs_url":"https://api.github.com/repos/influxdata/flux/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/influxdata/flux/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/influxdata/flux/git/refs{/sha}","trees_url":"https://api.github.com/repos/influxdata/flux/git/trees{/sha}","statuses_url":"https://api.github.com/repos/influxdata/flux/statuses/{sha}","languages_url":"https://api.github.com/repos/influxdata/flux/languages","stargazers_url":"https://api.github.com/repos/influxdata/flux/stargazers","contributors_url":"https://api.github.com/repos/influxdata/flux/contributors","subscribers_url":"https://api.github.com/repos/influxdata/flux/subscribers","subscription_url":"https://api.github.com/repos/influxdata/flux/subscription","commits_url":"https://api.github.com/repos/influxdata/flux/commits{/sha}","git_commits_url":"https://api.github.com/repos/influxdata/flux/git/commits{/sha}","comments_url":"https://api.github.com/repos/influxdata/flux/comments{/number}","issue_comment_url":"https://api.github.com/repos/influxdata/flux/issues/comments{/number}","contents_url":"https://api.github.com/repos/influxdata/flux/contents/{+path}","compare_url":"https://api.github.com/repos/influxdata/flux/compare/{base}...{head}","merges_url":"https://api.github.com/repos/influxdata/flux/merges","archive_url":"https://api.github.com/repos/influxdata/flux/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/influxdata/flux/downloads","issues_url":"https://api.github.com/repos/influxdata/flux/issues{/number}","pulls_url":"https://api.github.com/repos/influxdata/flux/pulls{/number}","milestones_url":"https://api.github.com/repos/influxdata/flux/milestones{/number}","notifications_url":"https://api.github.com/repos/influxdata/flux/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/influxdata/flux/labels{/name}","releases_url":"https://api.github.com/repos/influxdata/flux/releases{/id}","deployments_url":"https://api.github.com/repos/influxdata/flux/deployments","created_at":"2018-06-14T13:32:57Z","updated_at":"2019-01-02T17:19:28Z","pushed_at":"2019-01-02T17:42:50Z","git_url":"git://github.com/influxdata/flux.git","ssh_url":"git@github.com:influxdata/flux.git","clone_url":"https://github.com/influxdata/flux.git","svn_url":"https://github.com/influxdata/flux","homepage":"https://influxdata.com","size":2847,"stargazers_count":65,"watchers_count":65,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":237,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":5,"open_issues":237,"watchers":65,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/influxdata/flux/pulls/288"},"html":{"href":"https://github.com/influxdata/flux/pull/288"},"issue":{"href":"https://api.github.com/repos/influxdata/flux/issues/288"},"comments":{"href":"https://api.github.com/repos/influxdata/flux/issues/288/comments"},"review_comments":{"href":"https://api.github.com/repos/influxdata/flux/pulls/288/comments"},"review_comment":{"href":"https://api.github.com/repos/influxdata/flux/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/influxdata/flux/pulls/288/commits"},"statuses":{"href":"https://api.github.com/repos/influxdata/flux/statuses/ffc9df2824ff5342a76533943decb86a88086b48"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"nathanielc"}}