{"record":{"id":"cc543a8c76c8899c","repo":"nautechsystems/nautilus_trader","slug":"failed-to-load-signals-e","errorCode":null,"errorMessage":"Failed to load signals: {e}","messagePattern":"Failed to load signals: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/queries.rs","lineNumber":1608,"sourceCode":"        .await\n        .map(|_| ())\n        .map_err(|e| anyhow::anyhow!(\"Failed to insert into signal table: {e}\"))\n    }\n\n    /// Loads all `Signal` entries by `name` via the provided `pool`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the SQL SELECT or deserialization fails.\n    pub async fn load_signals(pool: &PgPool, name: &str) -> anyhow::Result<Vec<Signal>> {\n        sqlx::query_as::<_, SignalRow>(\n            r#\"SELECT * FROM \"signal\" WHERE name = $1 ORDER BY ts_init ASC\"#,\n        )\n        .bind(name)\n        .fetch_all(pool)\n        .await\n        .map(|rows| rows.into_iter().map(|row| row.0).collect())\n        .map_err(|e| anyhow::anyhow!(\"Failed to load signals: {e}\"))\n    }\n\n    /// Inserts a `CustomData` entry via the provided `pool`.\n    ///\n    /// Serializes the model `CustomData` to full JSON and stores it in the JSONB `value` column.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the SQL INSERT operation fails.\n    pub async fn add_custom_data(pool: &PgPool, data: &CustomData) -> anyhow::Result<()> {\n        let json_bytes = serde_json::to_vec(data)\n            .map_err(|e| anyhow::anyhow!(\"CustomData must be valid JSON: {e}\"))?;\n        let value_json: serde_json::Value = serde_json::from_slice(&json_bytes)\n            .map_err(|e| anyhow::anyhow!(\"CustomData value must be valid JSON: {e}\"))?;\n        let data_type_obj = value_json\n            .get(\"data_type\")\n            .and_then(|v| v.as_object())\n            .ok_or_else(|| anyhow::anyhow!(\"CustomData JSON missing data_type\"))?;","sourceCodeStart":1590,"sourceCodeEnd":1626,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/queries.rs#L1590-L1626","documentation":"Raised by `load_signals` when the SELECT of all `signal` rows filtered by `name` fails at the database level. The raw sqlx error is wrapped with `anyhow::anyhow!` and this message; it does not indicate missing rows (that returns an empty vec), only that the query itself failed.","triggerScenarios":"Calling `load_signals(pool, name)` when the `signal` table doesn't exist, the connection fails, pool is exhausted, or the query text/columns mismatch the current schema.","commonSituations":"Migrations not applied; using a pool pointing at the wrong database; transient network drops; PostgreSQL restart during the query.","solutions":["Inspect the wrapped sqlx error message for the DB-level cause.","Ensure migrations created the `signal` table with a `name` column.","Verify the pool points to the expected database.","Add retry logic for transient connection failures."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"let exists: bool = sqlx::query_scalar(\n    \"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'signal')\")\n    .fetch_one(pool).await?;\nanyhow::ensure!(exists, \"signal table missing; run migrations\");","typeGuard":null,"tryCatchPattern":"let signals = retry_backoff(3, || load_signals(&pool, name.clone())).await\n    .map_err(|e| e.context(\"loading signals failed after retries\"))?;","preventionTips":["Apply migrations before querying","Verify pool points at the expected database","Add bounded retries for transient network errors","Monitor PostgreSQL restarts"],"tags":["database","sqlx","query"],"backgroundTag":"sql-query-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}