Skip to content

fix: handle null review comment commit in parseGraphQLComment (fixes #9159) - #9168

Merged
Alex Ross (alexr00) merged 2 commits into
microsoft:mainfrom
hungud:fix/9159-null-commit-typeerror
Nov 11, 2026
Merged

Alex Ross (alexr00) merged 2 commits into
microsoft:mainfrom
hungud:fix/9159-null-commit-typeerror

Conversation

@hungud

@hungud Uong Dong Hung (hungud) commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #9159

When a Pull Request has detached or outdated review comments (e.g. after a rebase or force-push), the GitHub GraphQL API returns commit: null. Attempting to access comment.commit.oid throws an uncaught TypeError: Cannot read properties of null (reading 'oid'), preventing the Pull Request timeline from opening.

Changes

  • Safely extract commit OID with optional chaining: commitId: comment.commit?.oid, in src/github/utils.ts.
  • Update GraphQL.ReviewComment interface in src/github/graphql.ts to reflect nullable commit schema (commit?: { oid: string } | null;).
  • Add unit test in src/test/github/utils.test.ts covering review comments with null commit.

Verification & QA Proofs

1. VS Code GUI Action Verification
View Red GUI (VS Code PR Description View Crash)

Red VS Code UI

View Green GUI (Clean UI - PR Timeline Loaded Safely)

Green VS Code UI


2. Unit & Integration Test Proofs
View Terminal Test Execution

01_red_test_reproduced

02_green_test_passed


Contributed by Henry U. (Uong Dong Hung)

@hungud

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company=zentomedia.net

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change to handle review comments with null commits.

No open issues 🎉

What changed in this PR

Fixes #9159 by allowing review comments with null commits to be parsed without blocking the pull request timeline.

Changes:

  • Uses optional chaining when reading a review comment’s commit OID.
  • Makes commit and originalCommit optional and nullable in the GraphQL interface.
  • Adds a regression test verifying that null commits are handled while preserving the original commit ID.
File Description
src/​test/​github/​utils.test.ts Adds regression coverage for review comments with null commits.
src/​github/​utils.ts Safely reads the commit OID with optional chaining.
src/​github/​graphql.ts Updates review-comment types to allow absent or null commits.

Review effort: Balanced

…icrosoft#9159)

When review comments are detached or outdated following a rebase/force-push,
GitHub GraphQL API returns null for the comment's commit object.
Directly accessing comment.commit.oid resulted in an unhandled TypeError.

Safely access comment.commit?.oid with fallback to comment.originalCommit?.oid.
Includes unit test verifying parsing behavior when commit is null.
@hungud
Uong Dong Hung (hungud) force-pushed the fix/9159-null-commit-typeerror branch from 9231b83 to 9c35f39 Compare November 11, 2026 07:33
Copilot AI balanced review requested due to automatic review settings November 11, 2026 07:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the change handling null review-comment commits in pull request timelines.

No open issues 🎉

Review effort: Balanced

@alexr00

Copy link
Copy Markdown
Member

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.
@alexr00
Alex Ross (alexr00) enabled auto-merge (squash) November 11, 2026 10:36
@alexr00 Alex Ross (alexr00) added this to the 1.147.0 milestone Nov 11, 2026

@alexr00 Alex Ross (alexr00) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@alexr00

Copy link
Copy Markdown
Member

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.
@alexr00 Alex Ross (alexr00) self-assigned this Nov 11, 2026
@alexr00
Alex Ross (alexr00) merged commit b46ff02 into microsoft:main Nov 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants