Skip to content

Commit f563b06

Browse files
authored
chore(error): add detailed error message for auth entry not found (#468)
1 parent 981ebb1 commit f563b06

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/service/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ impl<'a, T> SharedResultExtRef<'a, T> for &'a Result<T, SharedError> {
157157

158158
#[macro_export]
159159
macro_rules! api_bail {
160-
( $fmt:literal $(, $($arg:expr) , *)?) => {
161-
return Err($crate::service::error::ApiError::new(&format!($fmt $(, $($arg) , *)?), axum::http::StatusCode::BAD_REQUEST).into())
160+
( $fmt:literal $(, $($arg:tt)*)?) => {
161+
return Err($crate::service::error::ApiError::new(&format!($fmt $(, $($arg)*)?), axum::http::StatusCode::BAD_REQUEST).into())
162162
};
163163
}
164164

165165
#[macro_export]
166166
macro_rules! api_error {
167-
( $fmt:literal $(, $($arg:expr) , *)?) => {
168-
$crate::service::error::ApiError::new(&format!($fmt $(, $($arg) , *)?), axum::http::StatusCode::BAD_REQUEST)
167+
( $fmt:literal $(, $($arg:tt)*)?) => {
168+
$crate::service::error::ApiError::new(&format!($fmt $(, $($arg)*)?), axum::http::StatusCode::BAD_REQUEST)
169169
};
170170
}

src/setup/auth_registry.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ impl AuthRegistry {
3636
let entries = self.entries.read().unwrap();
3737
match entries.get(&entry_ref.key) {
3838
Some(value) => Ok(serde_json::from_value(value.clone())?),
39-
None => api_bail!("Auth entry not found: {}", entry_ref.key),
39+
None => api_bail!(
40+
"Auth entry `{key}` not found.\n\
41+
Hint: If you're not referencing `{key}` in your flow, it will likely be caused by a previously persisted storage target using it. \
42+
You need to bring back the definition for the auth entry `{key}`, so that CocoIndex will be able to do a cleanup in the next `setup` run. \
43+
See https://cocoindex.io/docs/core/flow_def#auth-registry for more details.",
44+
key = entry_ref.key
45+
),
4046
}
4147
}
4248
}

0 commit comments

Comments
 (0)