Skip to content

Conversation

@brandur
Copy link
Contributor

@brandur brandur commented Nov 21, 2025

Aims to fix #1087.

One thing I hadn't accounted for is that it's actually possible to have
an embedded type that's not a struct. e.g.

type MyStruct struct {
    string // embedded non-struct
}

The simplified example above is not because we short circuit unless
properties are exported (and string is not exported because it starts
with a lower case letter), but if we have a similar case with a custom
type (e.g. type MyString string) then we can reproduce the error
described in #1087.

Fix the problem by making sure to check that a field is really a struct
before recursing back into getSortedUniqueFields. We're able to
simplify the function somewhat by handling all structs (anonymous or
not) in one spot since the logic is so similar.

Fixes #1087.

@brandur brandur force-pushed the brandur-anonymous-non-struct branch from 5e9074f to ebc0ce1 Compare November 21, 2025 07:55
@brandur brandur requested a review from bgentry November 21, 2025 08:02
Aims to fix #1087.

One thing I hadn't accounted for is that it's actually possible to have
an embedded type that's *not* a struct. e.g.

    type MyStruct struct {
        string // embedded non-struct
    }

The simplified example above is *not* because we short circuit unless
properties are exported (and `string` is not exported because it starts
with a lower case letter), but if we have a similar case with a custom
type (e.g. `type MyString string`) then we can reproduce the error
described in #1087.

Fix the problem by making sure to check that a field is really a struct
before recursing back into `getSortedUniqueFields`. We're able to
simplify the function somewhat by handling all structs (anonymous or
not) in one spot since the logic is so similar.

Fixes #1087.
@brandur brandur force-pushed the brandur-anonymous-non-struct branch from ebc0ce1 to 1a0dbf8 Compare November 21, 2025 10:13
@brandur brandur merged commit 5b1fa35 into master Nov 21, 2025
14 checks passed
@brandur brandur deleted the brandur-anonymous-non-struct branch November 21, 2025 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PeriodicJob ByArgs since 0.27.0 upgrade

3 participants