Skip to content

fix(feeds): handle null comment user in gh-sync content builder#602

Open
norrietaylor wants to merge 1 commit into
mainfrom
fix/feeds-gh-sync-null-comment-user
Open

fix(feeds): handle null comment user in gh-sync content builder#602
norrietaylor wants to merge 1 commit into
mainfrom
fix/feeds-gh-sync-null-comment-user

Conversation

@norrietaylor

@norrietaylor norrietaylor commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Root cause

GitHub's REST API returns "user": null for issue/PR comments authored by deleted or ghost accounts. In _build_content (src/distillery/feeds/github_sync.py), the comment author was read with:

author = comment.get("user", {}).get("login", "unknown")

dict.get("user", {}) only returns the {} default when the key is absent. When the key is present with a null/None value, it returns None, so None.get("login", ...) raises AttributeError. This propagated out of _build_content_issue_to_entry, crashing the sync for the affected issue/PR (both sync() and sync_batched() paths).

Fix

Coerce a missing or null user object to an empty dict before the lookup:

user = comment.get("user") or {}
author = user.get("login", "unknown")

Comments from ghost accounts now attribute to "unknown" instead of aborting the sync. Surgical one-line change plus a clarifying comment.

Acceptance

  • New unit test TestBuildContent::test_comment_with_null_user reproduces the crash (fails with AttributeError before the fix) and passes after.
  • Full tests/test_github_sync.py and tests/test_feeds.py suites pass (171 tests).
  • ruff check and mypy --strict clean on the touched source file.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved GitHub comment rendering to properly handle comments from deleted or ghosted user accounts, now displaying "unknown" as the author instead of potential errors.
  • Tests

    • Added test coverage for comments from deleted GitHub user accounts.

GitHub returns "user": null for issue/PR comments authored by deleted or
ghost accounts. _build_content used comment.get("user", {}).get("login"),
which returns None (not the {} default) when the key is present-but-null,
raising AttributeError and crashing the entire sync for that issue/PR.

Coerce a missing/null user object to {} before the login lookup so such
comments attribute to "unknown" instead of aborting the sync.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Complex PR? Review this PR in Change Stack to move by importance, not file order.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 15b9b826-a089-41ec-9a88-324b0a80c0c3

📥 Commits

Reviewing files that changed from the base of the PR and between 5a437a2 and cd50767.

📒 Files selected for processing (2)
  • src/distillery/feeds/github_sync.py
  • tests/test_github_sync.py

📝 Walkthrough

Walkthrough

This PR fixes a robustness issue in GitHub comment rendering where the API returns "user": null for deleted or ghost accounts. The fix normalizes null user fields to empty dicts before extracting login information, ensuring the "unknown" author fallback works reliably. A new test verifies the behavior for both null and valid user cases.

Changes

Null user handling in GitHub comments

Layer / File(s) Summary
Comment rendering with null user fallback
src/distillery/feeds/github_sync.py, tests/test_github_sync.py
_build_content normalizes potentially-null GitHub comment user fields to empty dicts before extracting login, ensuring the "unknown" author fallback works for deleted/ghost accounts. Test added for null user case alongside existing valid user login behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • norrietaylor/distillery#305: Both PRs modify GitHub sync author handling to cope with user: null payloads (main PR in github_sync.py comment rendering via _build_content, retrieved PR in github_sync.py issue/PR entry author derivation), so they are directly related at the GitHub "null user" edge-case level.

Poem

🐰 A comment with no user to claim,
Ghost accounts left with no name—
We normalize the null with care,
So "unknown" renders fair and square!
A simple fix, but oh so grand,
For deleted users understand.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing handling of null comment users in the GitHub sync content builder, which is the core fix addressing the AttributeError crash.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant