massive-com / massive-com/client-go
Comparison filters on ListNews (PublishedUtc.gte/gt/lte/lt) are unconstructible from outside the gen package
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:
-
The
unionfield 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. -
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
RequestEditorFnthat manually appendspublished_utc.gteto the query string (bypassing the typed param entirely). reflect+unsafeto 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/v3v3.1.0andv3.3.0(verified both)- Go 1.26
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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