Skip to content

events: marshal CodeCommitEventTime from a value receiver - #649

Open
Yeagerist0 wants to merge 1 commit into
aws:mainfrom
Yeagerist0:fix/codecommit-eventtime-marshal
Open

Yeagerist0 wants to merge 1 commit into
aws:mainfrom
Yeagerist0:fix/codecommit-eventtime-marshal

Conversation

@Yeagerist0

Copy link
Copy Markdown

CodeCommitEventTime.MarshalJSON has a pointer receiver, so encoding/json only calls it for addressable values. json.Marshal(record) on a CodeCommitRecord (not &record) writes "eventTime":{}, and UnmarshalJSON can't read that back.

Moved MarshalJSON to a value receiver; json.Marshal already writes null for a nil pointer, so the explicit nil check is no longer needed. The new test round-trips a record passed by value; it fails on main and passes now. go test ./events is green.

Disclosure: I used Claude Code to help find and write this; I reproduced the bug and ran the tests myself.

MarshalJSON had a pointer receiver, so json.Marshal only used it when
the field was addressable. Marshalling a CodeCommitRecord by value
silently wrote "eventTime":{} instead of the timestamp, which
UnmarshalJSON then cannot read back.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.07%. Comparing base (4111853) to head (b48c04d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #649      +/-   ##
==========================================
+ Coverage   82.04%   82.07%   +0.03%     
==========================================
  Files          37       37              
  Lines        1487     1484       -3     
==========================================
- Hits         1220     1218       -2     
+ Misses        264      263       -1     
  Partials        3        3              

☔ 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.

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.

2 participants