massive-com / massive-com/client-go

Comparison filters on ListNews (PublishedUtc.gte/gt/lte/lt) are unconstructible from outside the gen package

Open
#579 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
198
Forks
59
Avg merge
33m
Merged PRs (30d)
2

Description

Description

The ListNewsParams struct in rest/gen/client.gen.go exposes comparison filters
for published_utc (and similarly for ticker.gte/gt/lte/lt) as anonymous structs
with a single unexported field:

// rest/gen/client.gen.go
type ListNewsParams struct {
    // ...
    PublishedUtcGte *struct {
        union json.RawMessage
    } `form:"published_utc.gte,omitempty" json:"published_utc.gte,omitempty"`

    PublishedUtcGt  *struct{ union json.RawMessage } `...`
    PublishedUtcLte *struct{ union json.RawMessage } `...`
    PublishedUtcLt  *struct{ union json.RawMessage } `...`
    // ...
}

These fields appear to come from a oneOf<datetime, date> schema in the OpenAPI
spec. oapi-codegen normally emits FromX / AsX / MergeX helpers for union
types, but no such helpers are generated here:

$ grep -E 'FromListNewsParamsPublishedUtcGte|AsListNewsParamsPublishedUtcGte' rest/gen
(no matches)

Why this is a problem

Two compounding issues make these fields unusable from outside the gen package:

  1. The union field is unexported. Per the Go spec (Type identity):

    Non-exported field names from different packages are always different.

    So callers cannot construct an equivalent struct literal — struct{ union json.RawMessage }{...} declared elsewhere is a different type and is not assignable to *ListNewsParams.PublishedUtcGte.

  2. No exported constructor or setter is generated.

The serialization side of the SDK does work — NewListNewsRequest calls runtime.StyleParamWithLocation on *params.PublishedUtcGte and produces the correct published_utc.gte=... query parameter — but there is no supported way to put a value into the field.

The only workarounds available to consumers are:

  • A RequestEditorFn that manually appends published_utc.gte to the query string (bypassing the typed param entirely).
  • reflect + unsafe to set the unexported field.

Affected fields include (non-exhaustive):

  • ListNewsParams.PublishedUtcGte / Gt / Lte / Lt
  • Likely the same pattern on other endpoints that filter by published_utc, timestamp, etc.

Versions

  • github.com/massive-com/client-go/v3 v3.1.0 and v3.3.0 (verified both)
  • Go 1.26

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in rest/gen/client.gen.go by tracing ListNewsParams.PublishedUtcGte/Gt/Lte/Lt and the corresponding ticker fields back to the oneOf<datetime, date> schema and generation setup. Determine why union helpers are missing, then regenerate or adjust the generated output so callers have an exported way to construct these filters. Confirm that NewListNewsRequest still serializes the values as published_utc.gte/gt/lte/lt query parameters.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.