Skip to content

Commit 5b11eab

Browse files
committed
[slop]fix(rivetkit): surface raw error messages instead of generic
1 parent 38d756b commit 5b11eab

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

engine/packages/error/src/error.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
use crate::INTERNAL_ERROR;
22
use crate::schema::RivetErrorSchema;
33
use serde::Serialize;
4-
use std::{fmt, sync::OnceLock};
5-
6-
static EXPOSE_INTERNAL_ERRORS: OnceLock<bool> = OnceLock::new();
7-
8-
fn expose_internal_errors() -> bool {
9-
*EXPOSE_INTERNAL_ERRORS
10-
.get_or_init(|| matches!(std::env::var("RIVET_EXPOSE_ERRORS").as_deref(), Ok("1")))
11-
}
4+
use std::fmt;
125

136
#[derive(Debug, Clone)]
147
pub struct RivetError {
@@ -36,7 +29,7 @@ impl RivetError {
3629
Self {
3730
schema: &INTERNAL_ERROR,
3831
meta,
39-
message: expose_internal_errors().then(|| format!("Internal error: {}", error)),
32+
message: Some(format!("{}", error)),
4033
}
4134
}
4235

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"code": "query_failed",
3+
"group": "sqlite",
4+
"message": "SQL query failed."
5+
}

rivetkit-rust/packages/rivetkit-core/src/actor/sqlite.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,11 @@ fn map_local_worker_error(error: anyhow::Error) -> anyhow::Error {
633633
return SqliteRuntimeError::Closed.build();
634634
}
635635

636-
error
636+
// User SQL errors (syntax, constraints, etc.)
637+
SqliteRuntimeError::QueryFailed {
638+
message: format!("{error}"),
639+
}
640+
.build()
637641
}
638642

639643
fn protocol_bind_params(params: Vec<BindParam>) -> Vec<protocol::SqliteBindParam> {

rivetkit-rust/packages/rivetkit-core/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub fn public_error_status_code(group: &str, code: &str) -> Option<u16> {
2020
| "complete_not_configured"
2121
| "timed_out",
2222
) => Some(400),
23+
("sqlite", "query_failed") => Some(400),
2324
_ => None,
2425
}
2526
}
@@ -192,6 +193,9 @@ pub(crate) enum SqliteRuntimeError {
192193
"Remote SQLite generation is stale: {reason}"
193194
)]
194195
RemoteFenceMismatch { reason: String },
196+
197+
#[error("query_failed", "SQL query failed.", "SQL query failed: {message}")]
198+
QueryFailed { message: String },
195199
}
196200

197201
#[derive(RivetError, Debug, Clone, Deserialize, Serialize)]

0 commit comments

Comments
 (0)