upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/git
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-02-03 22:00:31 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-02-03 22:00:31 +0000
commit22d93ea5e707e99d67ab367d60c7a9d867b7665c (patch)
treec9a9272252782c54b9f7028a8c8c6bdeb8a1350d /src/git
parentf200bd1bde04ff79a40c8d73df0edde2cf28493c (diff)
Add error logging to all git handler IO operations
Previously, some IO errors in git handlers were logged while others were not, leading to inconsistent observability. Additionally, the HTTP layer logged all git errors redundantly, adding no useful context beyond what was already logged at the source. Changes: - Add error logging to all previously unlogged IO operations in handle_upload_pack and handle_receive_pack (stdin writes, stdout/stderr reads, process waits) - Remove redundant error logging at HTTP layer since all errors are now logged at their source with full context - Ensures consistent error-level logging for all git subprocess failures This provides complete observability of git operations while eliminating duplicate log entries that don't add value.
Diffstat (limited to 'src/git')
-rw-r--r--src/git/handlers.rs40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/git/handlers.rs b/src/git/handlers.rs
index 7244abb..28cb47f 100644
--- a/src/git/handlers.rs
+++ b/src/git/handlers.rs
@@ -156,7 +156,10 @@ pub async fn handle_upload_pack(
156 stdin 156 stdin
157 .write_all(&request_body) 157 .write_all(&request_body)
158 .await 158 .await
159 .map_err(GitError::IoError)?; 159 .map_err(|e| {
160 error!("Failed to write to git upload-pack stdin: {}", e);
161 GitError::IoError(e)
162 })?;
160 // Close stdin to signal end of input 163 // Close stdin to signal end of input
161 drop(stdin); 164 drop(stdin);
162 } 165 }
@@ -170,7 +173,10 @@ pub async fn handle_upload_pack(
170 stdout 173 stdout
171 .read_to_end(&mut output) 174 .read_to_end(&mut output)
172 .await 175 .await
173 .map_err(GitError::IoError)?; 176 .map_err(|e| {
177 error!("Failed to read git upload-pack stdout: {}", e);
178 GitError::IoError(e)
179 })?;
174 } 180 }
175 181
176 if let Some(stderr) = git.take_stderr() { 182 if let Some(stderr) = git.take_stderr() {
@@ -178,11 +184,17 @@ pub async fn handle_upload_pack(
178 stderr 184 stderr
179 .read_to_end(&mut stderr_output) 185 .read_to_end(&mut stderr_output)
180 .await 186 .await
181 .map_err(GitError::IoError)?; 187 .map_err(|e| {
188 error!("Failed to read git upload-pack stderr: {}", e);
189 GitError::IoError(e)
190 })?;
182 } 191 }
183 192
184 // Wait for process 193 // Wait for process
185 let status = git.wait().await.map_err(GitError::IoError)?; 194 let status = git.wait().await.map_err(|e| {
195 error!("Failed to wait for git upload-pack process: {}", e);
196 GitError::IoError(e)
197 })?;
186 198
187 if !status.success() { 199 if !status.success() {
188 let stderr_str = String::from_utf8_lossy(&stderr_output); 200 let stderr_str = String::from_utf8_lossy(&stderr_output);
@@ -299,7 +311,10 @@ pub async fn handle_receive_pack(
299 stdin 311 stdin
300 .write_all(&request_body) 312 .write_all(&request_body)
301 .await 313 .await
302 .map_err(GitError::IoError)?; 314 .map_err(|e| {
315 error!("Failed to write to git receive-pack stdin: {}", e);
316 GitError::IoError(e)
317 })?;
303 drop(stdin); 318 drop(stdin);
304 } 319 }
305 320
@@ -312,7 +327,10 @@ pub async fn handle_receive_pack(
312 stdout 327 stdout
313 .read_to_end(&mut output) 328 .read_to_end(&mut output)
314 .await 329 .await
315 .map_err(GitError::IoError)?; 330 .map_err(|e| {
331 error!("Failed to read git receive-pack stdout: {}", e);
332 GitError::IoError(e)
333 })?;
316 } 334 }
317 335
318 if let Some(stderr) = git.take_stderr() { 336 if let Some(stderr) = git.take_stderr() {
@@ -320,11 +338,17 @@ pub async fn handle_receive_pack(
320 stderr 338 stderr
321 .read_to_end(&mut stderr_output) 339 .read_to_end(&mut stderr_output)
322 .await 340 .await
323 .map_err(GitError::IoError)?; 341 .map_err(|e| {
342 error!("Failed to read git receive-pack stderr: {}", e);
343 GitError::IoError(e)
344 })?;
324 } 345 }
325 346
326 // Wait for process 347 // Wait for process
327 let status = git.wait().await.map_err(GitError::IoError)?; 348 let status = git.wait().await.map_err(|e| {
349 error!("Failed to wait for git receive-pack process: {}", e);
350 GitError::IoError(e)
351 })?;
328 352
329 if !status.success() { 353 if !status.success() {
330 let stderr_str = String::from_utf8_lossy(&stderr_output); 354 let stderr_str = String::from_utf8_lossy(&stderr_output);