Skip to content

Decode explicit zero attachment durations - #123

Open
ac1982 wants to merge 1 commit into
gorilla:mainfrom
ac1982:fix/json-zero-duration
Open

ac1982 wants to merge 1 commit into
gorilla:mainfrom
ac1982:fix/json-zero-duration

Conversation

@ac1982

@ac1982 ac1982 commented Oct 10, 2026

Copy link
Copy Markdown

What type of PR is this?

  • Bug Fix

Description

Decoding {"duration_in_seconds":0} into a JSONAttachment whose duration is already five seconds leaves the old five-second value intact. This affects callers that reuse an attachment while reading updated JSON.

Use an optional numeric field in the decoding helper so explicit zero resets the duration, while missing/null values preserve it. Fractional seconds and the existing treatment of negative values remain covered by tests.

Related Tickets & Documents

All-state searches found no report or fix for this decoding behavior. #121 addresses marshaling attachment values in seconds; this fixes decoding into an existing attachment and changes no marshaling code.

Added/updated tests?

  • Yes: zero fails on the base, with fractional, missing, null and negative cases as compatibility checks.

Run verifications and test

  • make verify passes (golangci-lint, gosec, govulncheck).
  • make test passes with the race detector, 92.7% statement coverage.

Tests/security checks used Go 1.27.1 on Linux arm64. The lint executable is a wrapper running golangci-lint v1.64.8 under Go 1.24.13 with CGO disabled, because v1 lint cannot read Go 1.27 export data and the Go 1.24 CGO linker expects unavailable ld.gold. This is not a claim to have run the upstream Go 1.20/1.21, macOS or Windows matrix. govulncheck reports no reachable vulnerabilities; it notes advisories in imported packages/modules outside the detected call paths.

AI assistance: prepared and tested with Codex.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant