Files
gitea/modules/structs/issue_milestone.go
T
silverwind 5aea433c71 fix(api): don't panic on null milestone due_on (#40171)
On release/v28, `PATCH /repos/{owner}/{repo}/milestones/{id}` with
`"due_on": null`, the documented way to remove a deadline, returns HTTP
500. The backport https://github.com/go-gitea/gitea/pull/39921 changed
`EditMilestoneOption.Deadline` to `optional.Option[*string]`, which
decodes `null` as a slice holding a nil pointer, and the go-chi/binding
validator panics on that element (`reflect: call of
reflect.Value.Interface on zero Value`).

The field has no binding rules, so tag it `form:"-"` to skip validation.
main is unaffected since https://github.com/go-gitea/gitea/pull/39528
moved the binding into Gitea.
2026-11-04 06:08:08 +00:00

63 lines
2.1 KiB
Go

// Copyright 2016 The Gogs Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
import (
"time"
"gitea.dev/modules/optional"
)
// Milestone milestone is a collection of issues on one repository
type Milestone struct {
// ID is the unique identifier for the milestone
ID int64 `json:"id"`
// Title is the title of the milestone
Title string `json:"title"`
// Description provides details about the milestone
Description string `json:"description"`
// State indicates if the milestone is open or closed
State StateType `json:"state"`
// OpenIssues is the number of open issues in this milestone
OpenIssues int `json:"open_issues"`
// ClosedIssues is the number of closed issues in this milestone
ClosedIssues int `json:"closed_issues"`
// swagger:strfmt date-time
Created time.Time `json:"created_at"`
// swagger:strfmt date-time
Updated *time.Time `json:"updated_at"`
// swagger:strfmt date-time
Closed *time.Time `json:"closed_at"`
// swagger:strfmt date-time
Deadline *time.Time `json:"due_on"`
}
// CreateMilestoneOption options for creating a milestone
type CreateMilestoneOption struct {
// Title is the title of the new milestone
Title string `json:"title"`
// Description provides details about the milestone
Description string `json:"description"`
// swagger:strfmt date-time
// Deadline is the due date for the milestone
Deadline *time.Time `json:"due_on"`
// enum: ["open","closed"]
// State indicates the initial state of the milestone
State string `json:"state"`
}
// EditMilestoneOption options for editing a milestone
type EditMilestoneOption struct {
// Title is the updated title of the milestone
Title string `json:"title"`
// Description provides updated details about the milestone
Description *string `json:"description"`
// State indicates the updated state of the milestone
// enum: ["open","closed"]
State *string `json:"state"`
// Deadline is the due date for the milestone, use null or empty string to remove the deadline
// swagger:strfmt date-time
Deadline optional.Option[*string] `json:"due_on,omitzero" form:"-"` // go-chi/binding panics validating the nil element a JSON null decodes to
}