-
Notifications
You must be signed in to change notification settings - Fork 0
Bug 2023624 - Some older repos have comments that have empty comment body and user object is null. The ETL script needs to handle these better instead of crashing #12
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -301,8 +301,15 @@ def extract_reviewers( | |||||
|
|
||||||
| reviewers = github_get(session, reviewers_url).json() | ||||||
|
|
||||||
| logger.info(f"Extracted {len(reviewers)} reviewers for PR #{pr_number}") | ||||||
| return reviewers | ||||||
| filtered = [r for r in reviewers if r.get("user") is not None] | ||||||
| skipped = len(reviewers) - len(filtered) | ||||||
| if skipped: | ||||||
| logger.info( | ||||||
| f"Skipped {skipped} reviewer(s) with null user for PR #{pr_number}" | ||||||
| ) | ||||||
|
|
||||||
| logger.info(f"Extracted {len(filtered)} reviewers for PR #{pr_number}") | ||||||
| return filtered | ||||||
|
|
||||||
|
|
||||||
| def extract_comments( | ||||||
|
|
@@ -329,8 +336,16 @@ def extract_comments( | |||||
| logger.info(f"Comments URL: {comments_url}") | ||||||
|
|
||||||
| comments = github_get(session, comments_url).json() | ||||||
| logger.info(f"Extracted {len(comments)} comments for PR #{pr_number}") | ||||||
| return comments | ||||||
|
|
||||||
| filtered = [c for c in comments if c.get("user") is not None and c.get("body")] | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto.
Suggested change
|
||||||
| skipped = len(comments) - len(filtered) | ||||||
| if skipped: | ||||||
| logger.info( | ||||||
| f"Skipped {skipped} comment(s) with null user or empty body for PR #{pr_number}" | ||||||
| ) | ||||||
|
|
||||||
| logger.info(f"Extracted {len(filtered)} comments for PR #{pr_number}") | ||||||
| return filtered | ||||||
|
|
||||||
|
|
||||||
| def sleep_for_rate_limit(resp: requests.Response) -> None: | ||||||
|
|
@@ -459,7 +474,7 @@ def transform_data(raw_data: list[dict], repo: str) -> dict: | |||||
| "target_repository": repo, | ||||||
| "date_reviewed": review.get("submitted_at"), | ||||||
| "reviewer_email": None, # TODO Placeholder for reviewer email extraction logic | ||||||
| "reviewer_username": review.get("user", {}).get("login", "None"), | ||||||
| "reviewer_username": (review.get("user") or {}).get("login"), | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the problem with the error message we saw is not that |
||||||
| "status": review.get("state"), | ||||||
| } | ||||||
| transformed_data["reviewers"].append(transformed_reviewer) | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Unless you expect
r["user"]to be validlyFalseor"", you can just