Skip to content

fix: Treat JSON null as a no-op in Timestamp.UnmarshalJSON - #4732

Open
aad1tyaaaaa wants to merge 1 commit into
google:masterfrom
aad1tyaaaaa:fix-timestamp-null
Open

aad1tyaaaaa wants to merge 1 commit into
google:masterfrom
aad1tyaaaaa:fix-timestamp-null

Conversation

@aad1tyaaaaa

Copy link
Copy Markdown

Fixes #4731.

Timestamp.UnmarshalJSON returned an error for a JSON null. encoding/json passes null to UnmarshalJSON for value (non-pointer) fields, so a null in any value Timestamp field (e.g. RepositoryRelease.CreatedAt, nullable in the release webhook payload) made the whole response or payload fail to decode.

This treats null as a no-op, following the encoding/json convention for Unmarshalers. Since every value Timestamp field goes through this method, one guard covers them all.

Testing: added a Null case to TestTimestamp_Unmarshal; it fails without the change and passes with it. ParseWebHook("release", ...) with "created_at": null now returns a *ReleaseEvent. go test ./... passes in all modules and custom-gcl run reports 0 issues.

AI disclosure: Claude (Claude Code) helped find the bug and draft the change, test, and this description; I reviewed and ran everything.

🤖 Generated with Claude Code

@google-cla

google-cla Bot commented Nov 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Nov 24, 2026
@gmlewis

gmlewis commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Thank you, @aad1tyaaaaa!

Unfortunately, this PR has two authors:

❌ https://github.com/google/go-github/commit/c87d5b2c52e6cc213e76a30001bc6d657d714cf7 Author: @aad1tyaaaaa <aadit**********swar​@gmail.com>
❌ https://github.com/google/go-github/commit/c87d5b2c52e6cc213e76a30001bc6d657d714cf7 Co-Author: <no****y​@anthropic.com>

and Anthropic is never going to sign the Google CLA. So you will either need to:

  1. Rewrite the commits to this PR from a single author (you), and then force-push the rewritten commit to this PR, or
  2. Close this PR and create a new one.

Sorry for the inconvenience!

Value (non-pointer) Timestamp fields such as RepositoryRelease.CreatedAt
receive the literal null from encoding/json, which previously failed to
parse and aborted decoding of the whole response or webhook payload.
@aad1tyaaaaa

Copy link
Copy Markdown
Author

Thanks @gmlewis! I've rewritten the commit with a single author (me) and force-pushed it (4700ebd). The code change itself is unchanged.

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.64%. Comparing base (5c5bbe8) to head (4700ebd).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4732   +/-   ##
=======================================
  Coverage   98.64%   98.64%           
=======================================
  Files         204      204           
  Lines       19162    19164    +2     
=======================================
+ Hits        18902    18904    +2     
  Misses        260      260           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @aad1tyaaaaa!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @Not-Dhananjay-Mishra

@aad1tyaaaaa

Copy link
Copy Markdown
Author

Thanks for the review, @gmlewis!

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

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timestamp.UnmarshalJSON fails on JSON null, breaking value Timestamp fields

2 participants