fix(selfhost): validate reporting exporter fast path - #4079
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4079 +/- ##
=======================================
Coverage 93.65% 93.65%
=======================================
Files 384 384
Lines 35865 35865
Branches 13160 13160
=======================================
Hits 33589 33589
Misses 1618 1618
Partials 658 658 🚀 New features to boost your workflow:
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-08 03:21:03 UTC
⏸️ Suggested Action - Manual Review
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
efb21f6 to
a507b0c
Compare
Motivation
COUNT(*)+MAX(timestamp)fingerprint and trusted any non-empty output DB, which could preserve stale or corrupted reporting snapshots and break observability freshness.Description
COUNT+MAXfingerprint with a content hash: for SQLite the scriptsqlite3 "$APP_DB" ".dump <table>"is hashed; for Postgres the script computes anmd5over orderedrow_to_json(t)output, and these per-table digests are composed into the source fingerprint inscripts/export-grafana-reporting-db.sh.reporting_db_ok()which requiressqlite3 "$OUT_DB" "PRAGMA quick_check;"to returnokbefore the fast-path can skip a rebuild, and include this check in the early-exit condition.hash_stdin()to robustly prefersha256sumthenshasum, and fail cleanly when neither exists.test/unit/selfhost-grafana-reporting.test.tsto cover an in-place SQLite edit that keeps count/max unchanged and to ensure a corrupted last-goodOUT_DBtriggers a rebuild instead of being preserved.Testing
git diff --checkand it succeeded.npx vitest run test/unit/selfhost-grafana-reporting.test.tsand the file's test suite passed (19 tests passed), including the two new regression tests.npm run test:cibut it could not complete due to existing unrelated TypeScript syntax errors insrc/queue/processors.ts, so the full CI gate was not run here.npm audit --audit-level=moderatebut the registry audit endpoint returned403 Forbidden, so the audit step could not be completed.Codex Task