Skip to content

Conversation

Itz-Agasta
Copy link

Description

This PR fixes a bug where timestamps returned by MongoDB with year 0 caused json.Marshal to fail with the error:

"Time.MarshalJSON: year outside of range [0,9999]"

The ReformatDate function in utils/typeutils/reformat.go previously only adjusted negative years and years > 9999. Year == 0 slipped through unmodified and triggered the runtime error.

Fixes #421

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Ran: go build ./... -> success

@Itz-Agasta Itz-Agasta changed the base branch from master to staging October 4, 2025 17:46
@vaibhav-datazip vaibhav-datazip added the hacktoberfest Issues open for Hacktoberfest contributors label Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest Issues open for Hacktoberfest contributors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: MongoDB timestamps with year 0 cause JSON marshaling error

2 participants