Skip to content

Commit 7e51005

Browse files
committed
fix: suggestions from code review
1 parent 28bd8d9 commit 7e51005

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

  • libs/@local/graph/api/src/rest/hashql

libs/@local/graph/api/src/rest/hashql/mod.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ async fn query_local_impl(
119119
Label::new(compilation.root_span, "failed to acquire postgres client"),
120120
);
121121

122-
diagnostic.add_message(Message::note(format!("{report:?}")));
122+
if cfg!(debug_assertions) {
123+
diagnostic.add_message(Message::note(format!("{report:?}")));
124+
} else {
125+
tracing::error!(?report, "failed to acquire postgres client");
126+
}
127+
123128
diagnostic
124129
})
125130
.into_status()
@@ -169,7 +174,7 @@ async fn run_query(
169174
.await;
170175

171176
result.unwrap_or_else(|error| {
172-
tracing::error!(?error, "panicked by trying to execute query");
177+
tracing::error!(?error, "panicked while executing query");
173178

174179
(
175180
StatusCode::INTERNAL_SERVER_ERROR,
@@ -180,6 +185,20 @@ async fn run_query(
180185
})
181186
}
182187

188+
fn deserialize_empty_inputs<'de, D>(deserializer: D) -> Result<Vec<()>, D::Error>
189+
where
190+
D: serde::Deserializer<'de>,
191+
{
192+
let inputs = serde::Deserialize::<'de>::deserialize(deserializer)?;
193+
if inputs.is_empty() {
194+
return Ok(inputs);
195+
}
196+
197+
Err(serde::de::Error::custom(
198+
"`inputs` must be an empty array until input support ships",
199+
))
200+
}
201+
183202
/// Request body for the `/hashql` endpoint.
184203
#[derive(serde::Deserialize, utoipa::ToSchema)]
185204
pub(crate) struct HashQlRequest {
@@ -190,6 +209,7 @@ pub(crate) struct HashQlRequest {
190209
dead_code,
191210
reason = "inputs will be required once HashQL input support ships"
192211
)]
212+
#[serde(deserialize_with = "deserialize_empty_inputs")]
193213
inputs: Vec<()>,
194214
}
195215

0 commit comments

Comments
 (0)