Skip to content

Policy/request.go has faulty DelayAction struct. #29

@jaceq

Description

@jaceq

Here:

UntilMinute int `json:"untilMinute,omitempty"`

is a bug, following struct is configured:

type DelayAction struct {
        DelayOption DelayType `json:"delayOption,omitempty"`
        UntilMinute int       `json:"untilMinute,omitempty"`
        UntilHour   int       `json:"untilHour,omitempty"`
        Duration    *Duration `json:"duration,omitempty"`
}

Problem is that if UntilMinute and / or UntilHour is 0 then argument is omitted as it's seen as empty (which in this case is not the case).
Due to this issue it's not possible to set any of those to 0.
According to: https://www.sohamkamani.com/blog/golang/2018-07-19-golang-omitempty/

Solution would be to switch field to:

 *int 

So, struct would look like that:

type DelayAction struct {
        DelayOption DelayType `json:"delayOption,omitempty"`
        UntilMinute *int       `json:"untilMinute,omitempty"`
        UntilHour   *int       `json:"untilHour,omitempty"`
        Duration    *Duration `json:"duration,omitempty"`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions