Dokploy monitoring API returns partial container metrics with HTTP 200 when a row read fails
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go, sqlite
- Ambito
- backend, observability
Direzione di ricerca
Leggi apps/monitoring/database/containers.go, concentrandoti su GetAllMetricsContainer e GetLastNContainerMetrics, poi esamina la riproduzione nell’issue. Verifica come ogni reader gestisce gli errori dopo aver iterato su rows; il lavoro è completato quando gli errori di iterazione vengono restituiti come errori e i test del database esistenti passano, e l’handler in apps/monitoring/main.go restituisce HTTP 500 per quegli errori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Dokploy monitoring API returns partial container metrics with HTTP 200 when a row read fails
Environment
- Dokploy commit
3e75dc64f391316df63a99fbef3e0df5bf7b9350 - Go 1.26, Linux (
golang:1.26image); the same code path runs on the released SQLite build
Summary
apps/monitoring/database/containers.go iterates rows.Next() in both metric readers but
never checks rows.Err(). When the SQLite driver fails mid-iteration (I/O error, corruption,
interrupted read), the loop simply ends and the function returns the rows collected so far
with a nil error. GET /metrics/containers?limit=all therefore answers 200 OK with a
truncated time series, and the dashboard renders the gap as if the metrics had ended.
Root cause
database/sql.Rows.Next returns false both when the result set ends normally and when the
driver reports an error; the error is deferred to Rows.Err(). Both readers only inspect the
error from Scan, so an iteration error looks identical to a clean end of data:
for rows.Next() { // false on error AND on success
if err := rows.Scan(&metricsJSON); err != nil {
return nil, err
}
...
}
return metrics, nil // iteration error is never read
Because no rows.Err() call follows the loop, the driver error (disk I/O error, a decode
failure, a cancelled context, …) is discarded and the collected prefix is indistinguishable
from a complete, successful result. The HTTP handler only branches on the returned error, so
it answers 200 with the partial slice.
Affected code
apps/monitoring/database/containers.go—GetAllMetricsContainer(loop ends with
return metrics, nil, norows.Err()).apps/monitoring/database/containers.go—GetLastNContainerMetricshas the same shape.apps/monitoring/main.go—GET /metrics/containersreturnsc.JSON(metrics)whenever
err == nil.
Reproduction
A driver that yields one row and then fails is enough; no database file is needed. Save this
as apps/monitoring/database/rows_err_test.go:
package database
import (
"context"
"database/sql"
"database/sql/driver"
"errors"
"io"
"testing"
)
type failDriver struct{}
func (failDriver) Open(string) (driver.Conn, error) { return failConn{}, nil }
type failConn struct{}
func (failConn) Prepare(string) (driver.Stmt, error) { return nil, io.EOF }
func (failConn) Close() error { return nil }
func (failConn) Begin() (driver.Tx, error) { return nil, io.EOF }
func (failConn) QueryContext(context.Context, string, []driver.NamedValue) (driver.Rows, error) {
return &failRows{}, nil
}
type failRows struct{ step int }
func (r *failRows) Columns() []string { return []string{"metrics_json"} }
func (r *failRows) Close() error { return nil }
func (r *failRows) Next(dest []driver.Value) error {
if r.step == 0 {
r.step++
dest[0] = `{"timestamp":"2026-01-01T00:00:00Z","CPU":1}`
return nil
}
return errors.New("disk I/O error while reading container_metrics")
}
func TestRowsErrIsReported(t *testing.T) {
sql.Register("faildriver", failDriver{})
db, _ := sql.Open("faildriver", "")
metrics, err := (&DB{DB: db}).GetAllMetricsContainer("web")
if err == nil {
t.Fatalf("returned %d partial metrics with nil error", len(metrics))
}
}
Run go test -run TestRowsErrIsReported ./database from apps/monitoring. Observed:
metrics=1 err=<nil>
BUG: driver error was swallowed; returned 1 partial metrics with nil error
Expected behavior
A row-iteration failure is surfaced: GetAllMetricsContainer / GetLastNContainerMetrics
return the error, and GET /metrics/containers answers 500 with the error message instead
of a truncated series.
Actual behavior
The partial slice is returned with nil error and served as 200 OK, so monitoring charts
silently lose data.
Suggested fix
After each for rows.Next() { ... } loop:
if err := rows.Err(); err != nil {
return nil, err
}
return metrics, nil
- Lingua principale
- TypeScript
- Stelle
- 38.8k
- Fork
- 3.2k
- Merge medio
- 1g 10h
- PR unite (30g)
- 110
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Dokploy/dokploy
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Dokploy/dokploy#6151 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Healthy Swarm task shows an empty `(Error:)` suffix on the last row of the Containers tabForse già presa @AyhamJo7 l’ha presa 4 giorni fa. Apertaneeds-triage🔍
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
Dokploy/dokploy#6115 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Global search (Cmd/Ctrl+J) never sorts results by relevanceForse già presa @hamidzr l’ha presa 6 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
Dokploy/dokploy#6107 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
`utils/dns/ovh.ts`: the zone-listing 403 handler replaces the provider's error instead of chaining itForse già presa @SyncWithRaj l’ha presa 8 giorni fa. Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
Dokploy/dokploy#6075 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
MongoDB with Replica Sets enabled: container exits with code 0 and restarts in a loop (generated startup script never waits on mongod)Forse già presa @ghazy2001 l’ha presa 10 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Dokploy/dokploy#6051 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Dokploy/dokploy
Issue simili
-
[Bug]: RUN_STARTED resets the run's tool-call tally even when a subscriber suppresses the eventApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
ag-ui-protocol/ag-ui#3504 ·
I maintainer di solito rispondono entro 1 giorno
-
area/profiles area/sessions comp/desktop desktop/chat desktop/sessions P2 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
NousResearch/hermes-agent#161712 ·
I maintainer di solito rispondono entro 1 giorno
-
bug p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
rothgar/rabble.radio#283 ·
I maintainer di solito rispondono entro 1 giorno
-
bug from-app needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
nightly-labs/openbot#19805 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
OHDSI/Data2Evidence#3760 ·
I maintainer di solito rispondono entro 3 giorni