Skip to content

Commit c707b18

Browse files
committed
fix: small correctness and quality improvements
- fix(webrpc): discard unused history row id in ClusterTaskHistory scan The SQL query selects both 'id' and 'task_id', but both were scanned into TaskID — the first value was silently overwritten. Use a discard target for the unused column. - fix(alertmanager): prevent duplicate alert output for sealing tasks Sealing tasks with >5 failures were printed twice: once for being a sealing task and once for exceeding the threshold. Use else-if so only one branch fires. - fix(indexing): fix 'failed to to insert' double-word typos In both task_ipni.go and task_pdp_ipni.go error messages. - fix(api): add missing Content-Type headers on JSON responses getSchema, getLayers (config API) and getSectors (sector API) were missing Content-Type: application/json — other handlers in the same files already set it. - fix(cli): 'Command separated' -> 'Comma-separated' in --db-host help Typo in CLI flag description and translation catalog.
1 parent 0d3f1c6 commit c707b18

File tree

8 files changed

+11
-9
lines changed

8 files changed

+11
-9
lines changed

alertmanager/alerts.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,7 @@ func taskFailureCheck(al *alerts) {
210210
for name, count := range tmap {
211211
if contains(sealingTasks, name) {
212212
al.alertMap[Name].alertString += fmt.Sprintf("Task: %s, Failures: %d. ", name, count)
213-
}
214-
if count > 5 {
213+
} else if count > 5 {
215214
al.alertMap[Name].alertString += fmt.Sprintf("Task: %s, Failures: %d. ", name, count)
216215
}
217216
}

cmd/curio/internal/translations/catalog.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/curio/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ func main() {
128128
&cli.StringFlag{
129129
Name: "db-host",
130130
EnvVars: []string{"CURIO_DB_HOST", "CURIO_HARMONYDB_HOSTS"},
131-
Usage: translations.T("Command separated list of hostnames for yugabyte cluster"),
131+
Usage: translations.T("Comma-separated list of hostnames for yugabyte cluster"),
132132
Value: "127.0.0.1",
133133
},
134134
&cli.StringFlag{
135135
Name: "db-host-cql",
136136
EnvVars: []string{"CURIO_DB_HOST_CQL"},
137-
Usage: translations.T("Command separated list of hostnames for yugabyte cluster"),
137+
Usage: translations.T("Comma-separated list of hostnames for yugabyte cluster"),
138138
Value: "",
139139
DefaultText: "<--db-host>",
140140
},

tasks/indexing/task_ipni.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ func (I *IPNITask) schedule(ctx context.Context, taskFunc harmonytask.AddTaskFun
562562

563563
n, err := tx.Exec(`INSERT INTO ipni_peerid (sp_id, priv_key, peer_id) VALUES ($1, $2, $3) ON CONFLICT(sp_id) DO NOTHING `, p.SpID, privKey, pid.String())
564564
if err != nil {
565-
return false, xerrors.Errorf("failed to to insert the key into DB: %w", err)
565+
return false, xerrors.Errorf("failed to insert the key into DB: %w", err)
566566
}
567567

568568
if n == 0 {

tasks/indexing/task_pdp_ipni.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ func (P *PDPIPNITask) schedule(ctx context.Context, taskFunc harmonytask.AddTask
542542

543543
n, err := tx.Exec(`INSERT INTO ipni_peerid (sp_id, priv_key, peer_id) VALUES ($1, $2, $3) ON CONFLICT(sp_id) DO NOTHING `, -1, privKey, pid.String())
544544
if err != nil {
545-
return false, xerrors.Errorf("failed to to insert the key into DB: %w", err)
545+
return false, xerrors.Errorf("failed to insert the key into DB: %w", err)
546546
}
547547

548548
if n == 0 {

web/api/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,14 @@ func getSch(w http.ResponseWriter, r *http.Request) {
157157
}
158158
allOpt(sch)
159159

160+
w.Header().Set("Content-Type", "application/json")
160161
apihelper.OrHTTPFail(w, json.NewEncoder(w).Encode(sch))
161162
}
162163

163164
func (c *cfg) getLayers(w http.ResponseWriter, r *http.Request) {
164165
var layers []string
165166
apihelper.OrHTTPFail(w, c.DB.Select(context.Background(), &layers, `SELECT title FROM harmony_config ORDER BY title`))
167+
w.Header().Set("Content-Type", "application/json")
166168
apihelper.OrHTTPFail(w, json.NewEncoder(w).Encode(layers))
167169
}
168170

web/api/sector/sector.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ func (c *cfg) getSectors(w http.ResponseWriter, r *http.Request) {
333333
sectors[i].Deals = fmt.Sprintf("Market: %d, DDO: %d", f05, ddo)
334334
}
335335
}
336+
w.Header().Set("Content-Type", "application/json")
336337
apihelper.OrHTTPFail(w, json.NewEncoder(w).Encode(map[string]any{"data": sectors}))
337338
}
338339

web/api/webrpc/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (a *WebRPC) ClusterTaskHistory(ctx context.Context, limit, offset int) ([]T
118118
var t TaskHistorySummary
119119
var posted, start, end time.Time
120120

121-
if err := rows.Scan(&t.TaskID, &t.Name, &t.TaskID, &posted, &start, &end, &t.Result, &t.Err, &t.CompletedBy); err != nil {
121+
if err := rows.Scan(new(int64), &t.Name, &t.TaskID, &posted, &start, &end, &t.Result, &t.Err, &t.CompletedBy); err != nil {
122122
return nil, err // Handle error
123123
}
124124

0 commit comments

Comments
 (0)