debug: add tracing to users_create_handler

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
Illia Polosukhin
2026-03-26 09:27:22 -07:00
co-authored by Claude Opus 4.6
parent 4bba26ea7f
commit 27c6d1d6b7
+13 -2
View File
@@ -48,6 +48,7 @@ pub async fn users_create_handler(
));
}
tracing::info!("users_create: passed validation, building record");
let user_id = Uuid::new_v4().to_string();
let now = chrono::Utc::now();
@@ -64,10 +65,15 @@ pub async fn users_create_handler(
metadata: serde_json::json!({}),
};
tracing::info!("users_create: calling create_user for {}", user_id);
store
.create_user(&user_record)
.await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
.map_err(|e| {
tracing::error!("users_create: create_user failed: {e}");
(StatusCode::INTERNAL_SERVER_ERROR, e.to_string())
})?;
tracing::info!("users_create: create_user succeeded");
// Generate a first API token so the new user can authenticate immediately.
// Hash the hex-encoded plaintext (what the user sends as Bearer token),
@@ -78,10 +84,15 @@ pub async fn users_create_handler(
let token_hash = crate::channels::web::auth::hash_token(&plaintext_token);
let token_prefix = &plaintext_token[..8];
tracing::info!("users_create: calling create_api_token");
let _token_record = store
.create_api_token(&user_id, "initial", &token_hash, token_prefix, None)
.await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
.map_err(|e| {
tracing::error!("users_create: create_api_token failed: {e}");
(StatusCode::INTERNAL_SERVER_ERROR, e.to_string())
})?;
tracing::info!("users_create: complete, returning response");
Ok(Json(serde_json::json!({
"id": user_record.id,