Skip to content

fix: make DayValue serialization timezone stable#1114

Open
princejha95 wants to merge 5 commits into
apache:masterfrom
princejha95:fix/day-test-ut
Open

fix: make DayValue serialization timezone stable#1114
princejha95 wants to merge 5 commits into
apache:masterfrom
princejha95:fix/day-test-ut

Conversation

@princejha95

Copy link
Copy Markdown
  • I have registered the PR changes.

What this PR does:
This PR make DayValue serialization timezone agnostic

Which issue(s) this PR fixes:
#887

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


NONE

@github-actions github-actions Bot added bug Something isn't working coding documentation Improvements or additions to documentation module/at milestone and removed bug Something isn't working documentation Improvements or additions to documentation module/at labels Apr 24, 2026
@thunguo thunguo requested a review from Copilot April 25, 2026 07:04
@codecov-commenter

codecov-commenter commented Apr 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 58.35%. Comparing base (84c991f) to head (59b8168).

Files with missing lines Patch % Lines
pkg/util/flagext/day.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1114      +/-   ##
==========================================
- Coverage   58.36%   58.35%   -0.02%     
==========================================
  Files         282      282              
  Lines       19405    19407       +2     
==========================================
- Hits        11326    11324       -2     
- Misses       7102     7104       +2     
- Partials      977      979       +2     

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

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.

Pull request overview

This PR addresses timezone-dependent DayValue serialization to make YAML and string formatting stable across environments (fixing UT failures in western timezones, per issue #887).

Changes:

  • Serialize DayValue via UTC (String() and MarshalYAML()) to avoid local-time date shifts.
  • Extend TestDayValueYAML with a test case that forces time.Local to a western timezone to catch regressions.
  • Remove an unused direct dependency (github.com/sijms/go-ora/v2) and record the change in changes/dev.md.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/util/flagext/day.go Forces DayValue serialization paths to format using UTC for stability.
pkg/util/flagext/day_test.go Adds a regression test covering western timezone behavior by overriding time.Local.
go.mod Drops unused direct go-ora requirement.
go.sum Removes corresponding go-ora checksum entries.
changes/dev.md Adds an entry referencing issue #887.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +72 to +75
// Test UTC-stable string and YAML serialization in western timezones.
{
loc, err := time.LoadLocation("America/Los_Angeles")
if err != nil {

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

The comment says this block tests "UTC-stable string and YAML serialization", but the test only asserts YAML marshal/unmarshal output and never checks DayValue.String(). Either add an assertion for the String() output under the modified time.Local, or adjust the comment to only mention YAML serialization to keep the test intent accurate.

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +95
type TestStruct struct {
Day *DayValue `yaml:"day"`
}
var testStruct TestStruct
testStruct.Day = &DayValue{}
require.NoError(t, testStruct.Day.Set("1985-06-02"))
expected := []byte(`day: "1985-06-02"
`)

actual, err := yaml.Marshal(testStruct)
require.NoError(t, err)
assert.Equal(t, expected, actual)

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

This new timezone-specific YAML test duplicates the prior "pointers of DayValue" block almost line-for-line. Consider making the pointer test table-driven (e.g., parameterize the location) or extracting a small helper to reduce duplication and make future additions (more timezones) easier.

Copilot uses AI. Check for mistakes.
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation module/at labels Apr 25, 2026
@thunguo

thunguo commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Consider whether any Copilot comments require action, and resolve the CI failures.

@thunguo thunguo requested a review from ssshr-66 April 25, 2026 12:26
@thunguo

thunguo commented May 23, 2026

Copy link
Copy Markdown
Contributor

Plz resolve the CI problem.

@ssshr-66 ssshr-66 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.

LGTM

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

Labels

bug Something isn't working coding documentation Improvements or additions to documentation milestone module/at

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants