aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/api.go
diff options
context:
space:
mode:
Diffstat (limited to 'dashboard/app/api.go')
-rw-r--r--dashboard/app/api.go58
1 files changed, 29 insertions, 29 deletions
diff --git a/dashboard/app/api.go b/dashboard/app/api.go
index 1e7d655c4..c7539c5f5 100644
--- a/dashboard/app/api.go
+++ b/dashboard/app/api.go
@@ -77,8 +77,8 @@ var apiHandlers = map[string]APIHandler{
"log_to_repro": nsHandler(apiLogToReproduce),
}
-type JSONHandler func(c context.Context, r *http.Request) (interface{}, error)
-type APIHandler func(c context.Context, payload io.Reader) (interface{}, error)
+type JSONHandler func(c context.Context, r *http.Request) (any, error)
+type APIHandler func(c context.Context, payload io.Reader) (any, error)
const (
maxReproPerBug = 10
@@ -126,7 +126,7 @@ func handleJSON(fn JSONHandler) http.Handler {
})
}
-func handleAPI(c context.Context, r *http.Request) (interface{}, error) {
+func handleAPI(c context.Context, r *http.Request) (any, error) {
client := r.PostFormValue("client")
method := r.PostFormValue("method")
log.Infof(c, "api %q from %q", method, client)
@@ -178,7 +178,7 @@ func contextNamespace(c context.Context) string {
// gcsPayloadHandler json.Decode the gcsURL from payload and stream pointed content.
// This function streams ungzipped content in order to be aligned with other wrappers/handlers.
func gcsPayloadHandler(handler APIHandler) APIHandler {
- return func(c context.Context, payload io.Reader) (interface{}, error) {
+ return func(c context.Context, payload io.Reader) (any, error) {
var gcsURL string
if err := json.NewDecoder(payload).Decode(&gcsURL); err != nil {
return nil, fmt.Errorf("json.NewDecoder(payload).Decode(&gcsURL): %w", err)
@@ -216,7 +216,7 @@ func nsHandler[Req any](handler func(context.Context, string, *Req) (any, error)
}
func typedHandler[Req any](handler func(context.Context, *Req) (any, error)) APIHandler {
- return func(ctx context.Context, payload io.Reader) (interface{}, error) {
+ return func(ctx context.Context, payload io.Reader) (any, error) {
req := new(Req)
if payload != nil {
if err := json.NewDecoder(payload).Decode(req); err != nil {
@@ -227,12 +227,12 @@ func typedHandler[Req any](handler func(context.Context, *Req) (any, error)) API
}
}
-func apiLogError(c context.Context, req *dashapi.LogEntry) (interface{}, error) {
+func apiLogError(c context.Context, req *dashapi.LogEntry) (any, error) {
log.Errorf(c, "%v: %v", req.Name, req.Text)
return nil, nil
}
-func apiBuilderPoll(c context.Context, ns string, req *dashapi.BuilderPollReq) (interface{}, error) {
+func apiBuilderPoll(c context.Context, ns string, req *dashapi.BuilderPollReq) (any, error) {
bugs, _, err := loadAllBugs(c, func(query *db.Query) *db.Query {
return query.Filter("Namespace=", ns).
Filter("Status<", BugStatusFixed)
@@ -277,7 +277,7 @@ func reportEmail(c context.Context, ns string) string {
return ""
}
-func apiCommitPoll(c context.Context, ns string, req *any) (interface{}, error) {
+func apiCommitPoll(c context.Context, ns string, req *any) (any, error) {
resp := &dashapi.CommitPollResp{
ReportEmail: reportEmail(c, ns),
}
@@ -343,7 +343,7 @@ func pollBackportCommits(c context.Context, ns string, count int) ([]string, err
return backportTitles, nil
}
-func apiUploadCommits(c context.Context, ns string, req *dashapi.CommitPollResultReq) (interface{}, error) {
+func apiUploadCommits(c context.Context, ns string, req *dashapi.CommitPollResultReq) (any, error) {
// This adds fixing commits to bugs.
err := addCommitsToBugs(c, ns, "", nil, req.Commits)
if err != nil {
@@ -444,7 +444,7 @@ func addCommitInfoToBugImpl(c context.Context, bug *Bug, com dashapi.Commit) (bo
return changed, nil
}
-func apiJobPoll(c context.Context, req *dashapi.JobPollReq) (interface{}, error) {
+func apiJobPoll(c context.Context, req *dashapi.JobPollReq) (any, error) {
if stop, err := emergentlyStopped(c); err != nil || stop {
// The bot's operation was aborted. Don't accept new crash reports.
return &dashapi.JobPollResp{}, err
@@ -455,17 +455,17 @@ func apiJobPoll(c context.Context, req *dashapi.JobPollReq) (interface{}, error)
return pollPendingJobs(c, req.Managers)
}
-func apiJobDone(c context.Context, req *dashapi.JobDoneReq) (interface{}, error) {
+func apiJobDone(c context.Context, req *dashapi.JobDoneReq) (any, error) {
err := doneJob(c, req)
return nil, err
}
-func apiJobReset(c context.Context, req *dashapi.JobResetReq) (interface{}, error) {
+func apiJobReset(c context.Context, req *dashapi.JobResetReq) (any, error) {
err := resetJobs(c, req)
return nil, err
}
-func apiUploadBuild(c context.Context, ns string, req *dashapi.Build) (interface{}, error) {
+func apiUploadBuild(c context.Context, ns string, req *dashapi.Build) (any, error) {
now := timeNow(c)
_, isNewBuild, err := uploadBuild(c, now, ns, req, BuildNormal)
if err != nil {
@@ -732,7 +732,7 @@ func managerList(c context.Context, ns string) ([]string, error) {
return managers, nil
}
-func apiReportBuildError(c context.Context, ns string, req *dashapi.BuildErrorReq) (interface{}, error) {
+func apiReportBuildError(c context.Context, ns string, req *dashapi.BuildErrorReq) (any, error) {
now := timeNow(c)
build, _, err := uploadBuild(c, now, ns, &req.Build, BuildFailed)
if err != nil {
@@ -762,7 +762,7 @@ const (
suppressedReportTitle = "suppressed report"
)
-func apiReportCrash(c context.Context, ns string, req *dashapi.Crash) (interface{}, error) {
+func apiReportCrash(c context.Context, ns string, req *dashapi.Crash) (any, error) {
if stop, err := emergentlyStopped(c); err != nil || stop {
// The bot's operation was aborted. Don't accept new crash reports.
return &dashapi.ReportCrashResp{}, err
@@ -1067,7 +1067,7 @@ func purgeOldCrashes(c context.Context, bug *Bug, bugKey *db.Key) {
log.Infof(c, "deleted %v crashes for bug %q", deleted, bug.Title)
}
-func apiReportFailedRepro(c context.Context, ns string, req *dashapi.CrashID) (interface{}, error) {
+func apiReportFailedRepro(c context.Context, ns string, req *dashapi.CrashID) (any, error) {
req.Title = canonicalizeCrashTitle(req.Title, req.Corrupted, req.Suppressed)
bug, err := findExistingBugForCrash(c, ns, []string{req.Title})
if err != nil {
@@ -1134,7 +1134,7 @@ func saveReproAttempt(c context.Context, bug *Bug, build *Build, log []byte) err
return nil
}
-func apiNeedRepro(c context.Context, ns string, req *dashapi.CrashID) (interface{}, error) {
+func apiNeedRepro(c context.Context, ns string, req *dashapi.CrashID) (any, error) {
if req.Corrupted {
resp := &dashapi.NeedReproResp{
NeedRepro: false,
@@ -1182,7 +1182,7 @@ func normalizeCrashTitle(title string) string {
return strings.TrimSpace(limitLength(title, maxTextLen))
}
-func apiManagerStats(c context.Context, ns string, req *dashapi.ManagerStatsReq) (interface{}, error) {
+func apiManagerStats(c context.Context, ns string, req *dashapi.ManagerStatsReq) (any, error) {
now := timeNow(c)
err := updateManager(c, ns, req.Name, func(mgr *Manager, stats *ManagerStats) error {
mgr.Link = req.Addr
@@ -1203,7 +1203,7 @@ func apiManagerStats(c context.Context, ns string, req *dashapi.ManagerStatsReq)
return nil, err
}
-func apiUpdateReport(c context.Context, ns string, req *dashapi.UpdateReportReq) (interface{}, error) {
+func apiUpdateReport(c context.Context, ns string, req *dashapi.UpdateReportReq) (any, error) {
bug := new(Bug)
bugKey := db.NewKey(c, "Bug", req.BugID, 0, nil)
if err := db.Get(c, bugKey, bug); err != nil {
@@ -1229,7 +1229,7 @@ func apiUpdateReport(c context.Context, ns string, req *dashapi.UpdateReportReq)
return nil, runInTransaction(c, tx, nil)
}
-func apiBugList(c context.Context, ns string, req *any) (interface{}, error) {
+func apiBugList(c context.Context, ns string, req *any) (any, error) {
keys, err := db.NewQuery("Bug").
Filter("Namespace=", ns).
KeysOnly().
@@ -1244,7 +1244,7 @@ func apiBugList(c context.Context, ns string, req *any) (interface{}, error) {
return resp, nil
}
-func apiLoadBug(c context.Context, ns string, req *dashapi.LoadBugReq) (interface{}, error) {
+func apiLoadBug(c context.Context, ns string, req *dashapi.LoadBugReq) (any, error) {
bug := new(Bug)
bugKey := db.NewKey(c, "Bug", req.ID, 0, nil)
if err := db.Get(c, bugKey, bug); err != nil {
@@ -1256,7 +1256,7 @@ func apiLoadBug(c context.Context, ns string, req *dashapi.LoadBugReq) (interfac
return loadBugReport(c, bug)
}
-func apiLoadFullBug(c context.Context, req *dashapi.LoadFullBugReq) (interface{}, error) {
+func apiLoadFullBug(c context.Context, req *dashapi.LoadFullBugReq) (any, error) {
bug, bugKey, err := findBugByReportingID(c, req.BugID)
if err != nil {
return nil, fmt.Errorf("failed to find the bug: %w", err)
@@ -1282,7 +1282,7 @@ func loadBugReport(c context.Context, bug *Bug) (*dashapi.BugReport, error) {
return createBugReport(c, bug, crash, crashKey, bugReporting, reporting)
}
-func apiAddBuildAssets(c context.Context, ns string, req *dashapi.AddBuildAssetsReq) (interface{}, error) {
+func apiAddBuildAssets(c context.Context, ns string, req *dashapi.AddBuildAssetsReq) (any, error) {
assets := []Asset{}
for i, toAdd := range req.Assets {
asset, err := parseIncomingAsset(c, toAdd, ns)
@@ -1323,7 +1323,7 @@ func parseIncomingAsset(c context.Context, newAsset dashapi.NewAsset, ns string)
}, nil
}
-func apiNeededAssetsList(c context.Context, req *any) (interface{}, error) {
+func apiNeededAssetsList(c context.Context, req *any) (any, error) {
return queryNeededAssets(c)
}
@@ -1704,7 +1704,7 @@ func handleRefreshSubsystems(w http.ResponseWriter, r *http.Request) {
}
}
-func apiSaveDiscussion(c context.Context, req *dashapi.SaveDiscussionReq) (interface{}, error) {
+func apiSaveDiscussion(c context.Context, req *dashapi.SaveDiscussionReq) (any, error) {
d := req.Discussion
newBugIDs := []string{}
for _, id := range d.BugIDs {
@@ -1743,7 +1743,7 @@ func recordEmergencyStop(c context.Context) error {
// Share crash logs for non-reproduced bugs with syz-managers.
// In future, this can also take care of repro exchange between instances
// in the place of syz-hub.
-func apiLogToReproduce(c context.Context, ns string, req *dashapi.LogToReproReq) (interface{}, error) {
+func apiLogToReproduce(c context.Context, ns string, req *dashapi.LogToReproReq) (any, error) {
build, err := loadBuild(c, ns, req.BuildID)
if err != nil {
return nil, err
@@ -1863,7 +1863,7 @@ func takeReproTask(c context.Context, ns, manager string) ([]byte, error) {
return log, err
}
-func apiCreateUploadURL(c context.Context, req *any) (interface{}, error) {
+func apiCreateUploadURL(c context.Context, req *any) (any, error) {
bucket := getConfig(c).UploadBucket
if bucket == "" {
return nil, errors.New("not configured")
@@ -1871,7 +1871,7 @@ func apiCreateUploadURL(c context.Context, req *any) (interface{}, error) {
return fmt.Sprintf("%s/%s.upload", bucket, uuid.New().String()), nil
}
-func apiSendEmail(c context.Context, req *dashapi.SendEmailReq) (interface{}, error) {
+func apiSendEmail(c context.Context, req *dashapi.SendEmailReq) (any, error) {
var headers mail.Header
if req.InReplyTo != "" {
headers = mail.Header{"In-Reply-To": []string{req.InReplyTo}}
@@ -1889,7 +1889,7 @@ func apiSendEmail(c context.Context, req *dashapi.SendEmailReq) (interface{}, er
// apiSaveCoverage reads jsonl data from payload and stores it to coveragedb.
// First payload jsonl line is a coveragedb.HistoryRecord (w/o session and time).
// Second+ records are coveragedb.JSONLWrapper.
-func apiSaveCoverage(c context.Context, payload io.Reader) (interface{}, error) {
+func apiSaveCoverage(c context.Context, payload io.Reader) (any, error) {
descr := new(coveragedb.HistoryRecord)
jsonDec := json.NewDecoder(payload)
if err := jsonDec.Decode(descr); err != nil {