Skip to content

Commit 00c82ea

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 00c82ea

File tree

12 files changed

+134
-132
lines changed

12 files changed

+134
-132
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: 116 additions & 116 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/curio/internal/translations/locales/en/out.gotext.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,9 @@
339339
"fuzzy": true
340340
},
341341
{
342-
"id": "Command separated list of hostnames for yugabyte cluster",
343-
"message": "Command separated list of hostnames for yugabyte cluster",
344-
"translation": "Command separated list of hostnames for yugabyte cluster",
342+
"id": "Comma-separated list of hostnames for yugabyte cluster",
343+
"message": "Comma-separated list of hostnames for yugabyte cluster",
344+
"translation": "Comma-separated list of hostnames for yugabyte cluster",
345345
"translatorComment": "Copied from source.",
346346
"fuzzy": true
347347
},

cmd/curio/internal/translations/locales/ko/messages.gotext.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,9 +1469,9 @@
14691469
"placeholder": null
14701470
},
14711471
{
1472-
"id": "Command separated list of hostnames for yugabyte cluster",
1472+
"id": "Comma-separated list of hostnames for yugabyte cluster",
14731473
"translation": "유가바이트 클러스터의 호스트 이름을 쉼표로 구분한 목록",
1474-
"message": "Command separated list of hostnames for yugabyte cluster",
1474+
"message": "Comma-separated list of hostnames for yugabyte cluster",
14751475
"placeholder": null
14761476
},
14771477
{

cmd/curio/internal/translations/locales/zh/messages.gotext.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,9 +1439,9 @@
14391439
"placeholder": null
14401440
},
14411441
{
1442-
"id": "Command separated list of hostnames for yugabyte cluster",
1442+
"id": "Comma-separated list of hostnames for yugabyte cluster",
14431443
"translation": "Yugabyte 集群的主机名命令分隔列表",
1444-
"message": "Command separated list of hostnames for yugabyte cluster",
1444+
"message": "Comma-separated list of hostnames for yugabyte cluster",
14451445
"placeholder": null
14461446
},
14471447
{

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
},

documentation/en/curio-cli/curio.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ COMMANDS:
2727
2828
GLOBAL OPTIONS:
2929
--color use color in display output (default: depends on output being a TTY)
30-
--db-host value Command separated list of hostnames for yugabyte cluster (default: "127.0.0.1") [$CURIO_DB_HOST, $CURIO_HARMONYDB_HOSTS]
31-
--db-host-cql value Command separated list of hostnames for yugabyte cluster (default: <--db-host>) [$CURIO_DB_HOST_CQL]
30+
--db-host value Comma-separated list of hostnames for yugabyte cluster (default: "127.0.0.1") [$CURIO_DB_HOST, $CURIO_HARMONYDB_HOSTS]
31+
--db-host-cql value Comma-separated list of hostnames for yugabyte cluster (default: <--db-host>) [$CURIO_DB_HOST_CQL]
3232
--db-name value Name of the Postgres database in Yugabyte cluster (default: "yugabyte") [$CURIO_DB_NAME, $CURIO_HARMONYDB_NAME]
3333
--db-user value Username for connecting to the Postgres database in Yugabyte cluster (default: "yugabyte") [$CURIO_DB_USER, $CURIO_HARMONYDB_USERNAME]
3434
--db-password value Password for connecting to the Postgres database in Yugabyte cluster (default: "yugabyte") [$CURIO_DB_PASSWORD, $CURIO_HARMONYDB_PASSWORD]

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

0 commit comments

Comments
 (0)