Skip to content

Always serialize the required JSON Feed items array - #124

Open
ac1982 wants to merge 1 commit into
gorilla:mainfrom
ac1982:fix/json-empty-items
Open

ac1982 wants to merge 1 commit into
gorilla:mainfrom
ac1982:fix/json-empty-items

Conversation

@ac1982

@ac1982 ac1982 commented Oct 10, 2026

Copy link
Copy Markdown

What type of PR is this?

  • Bug Fix

Description

An empty JSON feed currently omits items, whether generated by Feed.ToJSON, Feed.WriteJSON, or marshaling JSONFeed directly. The JSON Feed specification requires an array even when there are no entries.

Keep items in the encoded object and normalize a nil slice to an empty array in a value-receiver marshaler. Serialization works for values and pointers without modifying the source feed. The existing hub-only output fixture is updated to include the required array.

Related Tickets & Documents

No matching issue/PR found in all-state searches for empty feeds, items and JSON. #120 fixes field names and #121 fixes attachment marshaling; neither handles the top-level required array. This branch starts independently from current main.

Added/updated tests?

  • Yes: nil/empty item slices, direct JSON marshaling, and both generic feed serialization APIs. The nil/empty regression fails on the unmodified base. Existing populated-feed golden tests also pass.

Run verifications and test

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

Tests/security checks used Go 1.27.1 on Linux arm64. Lint used golangci-lint v1.64.8 under Go 1.24.13 with CGO disabled to avoid the v1 linter's incompatibility with Go 1.27 export data and this machine's missing ld.gold. The upstream Go 1.20/1.21, macOS and Windows matrix was not run locally. govulncheck reports no reachable vulnerabilities, while noting advisories outside 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