Skip to content
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
7 changes: 6 additions & 1 deletion openedx_webhooks/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,12 @@ def get_bot_comments(prid: PrId) -> Iterable[PrCommentDict]:
def get_catalog_info(repo_fullname: str) -> Dict:
"""Get the parsed catalog-info.yaml data from a repo, or {} if missing."""
yml = read_github_file(repo_fullname, "catalog-info.yaml", not_there="{}")
return yaml.safe_load(yml)
try:
data = yaml.safe_load(yml)
except yaml.YAMLError:
logging.warning(f"Failed to parse catalog-info.yaml file in {repo_fullname}.")
return {}
return data


@memoize_timed(minutes=60)
Expand Down
23 changes: 23 additions & 0 deletions tests/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
is_draft_pull_request,
is_internal_pull_request,
jira_details_for_pr,
get_catalog_info,
)


Expand Down Expand Up @@ -163,3 +164,25 @@ def test_jira_details_for_pr(fake_github, owner, repo, project, issuetype):
actual_project, actual_issuetype = jira_details_for_pr("test1", pr.as_json())
assert project == actual_project
assert issuetype == actual_issuetype


def test_get_malformed_catalog_info(mocker, caplog):
mocker.patch(
"openedx_webhooks.info.read_github_file",
lambda *args,**kwargs: "bad: 'yaml"
)
info = get_catalog_info("foo")
assert info == {}
assert "Failed to parse catalog-info.yaml file in foo." in caplog.text

def test_get_valid_catalog_info(mocker):
mocker.patch(
"openedx_webhooks.info.read_github_file",
lambda *args,**kwargs: "good: 'yaml'"
)
info = get_catalog_info("foo")
assert info == {"good": "yaml"}