From f933ae8886eadf25c1bd94a877a6fbca4b17d1c9 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Thu, 28 Aug 2025 13:17:27 +0200 Subject: [PATCH] feat: do not commit records with invalid responses from DIP This will retry HTTP requests on next start, e.g. if having wrong DNPM_DIP_URI config. --- src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index e4eda3b..c8cf9d6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use std::error::Error; use std::string::ToString; use std::sync::LazyLock; use std::time::Duration; -use tracing::{error, info}; +use tracing::{error, info, warn}; mod cli; mod http_client; @@ -174,9 +174,13 @@ async fn main() -> Result<(), Box> { producer.send(response_record, Duration::from_secs(1)).await }; - consumer - .commit_message(&msg, CommitMode::Async) - .expect("Cound not commit message: {}"); + if response.status_code == 200 || response.status_code == 201 || response.status_code == 400 || response.status_code == 422 { + consumer + .commit_message(&msg, CommitMode::Async) + .expect("Cound not commit message: {}"); + } else { + warn!("Unexpected Status Code for Request '{}': HTTP {}", &request_id, response.status_code); + } } } }