Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: URLs in LookML validator #500

Merged
merged 2 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spectacles/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(
field_name: str,
message: str,
severity: str,
lookml_url: str,
lookml_url: Optional[str],
file_path: Optional[str],
line_number: Optional[int] = None,
):
Expand Down
7 changes: 3 additions & 4 deletions spectacles/validators/lookml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Any
from typing import Dict, Any, Optional
from spectacles.client import LookerClient
from spectacles.exceptions import LookMLError

Expand All @@ -25,19 +25,18 @@ def validate(self, project: str, severity: str = "warning") -> Dict[str, Any]:
severity_level = NAME_TO_LEVEL[severity]
validation_results = self.client.lookml_validation(project)
errors = []
lookml_url: Optional[str] = None
for error in validation_results["errors"]:
if error["file_path"]:
lookml_url = (
self.client.base_url
+ "/projects/"
+ project
+ "/files/"
+ error["file_path"]
+ "/".join(error["file_path"].split("/")[1:])
)
if error["line_number"]:
lookml_url += "?line=" + str(error["line_number"])
else:
lookml_url = None

lookml_error = LookMLError(
model=error["model_id"],
Expand Down