diff --git a/Cargo.lock b/Cargo.lock index 67d9ff491..3a8344cfa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8646,6 +8646,7 @@ dependencies = [ "thiserror 1.0.69", "tokio", "tokio-util", + "tracing", "trustify-common", ] diff --git a/README.md b/README.md index 8d16c7ebe..338cd4bab 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,7 @@ podman-compose -f etc/deploy/compose/compose.yaml up Connect to PSQL: ```shell -env PGPASSWORD=eggs psql -U postgres -d trustify -h localhost -p 5432 +env PGPASSWORD=trustify psql -U postgres -d trustify -h localhost -p 5432 ``` If you don't have the `psql` command available, you can also use the `podman-compose` command: @@ -174,7 +174,7 @@ Point the app at an external db: ```shell cargo run --bin trustd api --help -RUST_LOG=info cargo run --bin trustd api --db-password eggs --devmode --auth-disabled +RUST_LOG=info cargo run --bin trustd api --db-password trustify --devmode --auth-disabled ``` ## Notes on models diff --git a/etc/deploy/compose/compose.yaml b/etc/deploy/compose/compose.yaml index 9e3566299..d6ff364c3 100644 --- a/etc/deploy/compose/compose.yaml +++ b/etc/deploy/compose/compose.yaml @@ -4,6 +4,6 @@ services: ports: - "5432:5432" environment: - POSTGRES_PASSWORD: "eggs" + POSTGRES_PASSWORD: "trustify" POSTGRES_DB: "trustify" restart: always diff --git a/modules/fundamental/src/error.rs b/modules/fundamental/src/error.rs index e598e66e7..60c38fbaa 100644 --- a/modules/fundamental/src/error.rs +++ b/modules/fundamental/src/error.rs @@ -1,6 +1,5 @@ use actix_web::{body::BoxBody, HttpResponse, ResponseError}; -use langchain_rust::agent::AgentError; -use langchain_rust::chain::ChainError; +use langchain_rust::{agent::AgentError, chain::ChainError}; use sea_orm::DbErr; use trustify_common::{decompress, error::ErrorInformation, id::IdError, purl::PurlErr}; use trustify_module_storage::service::StorageKeyError; @@ -61,24 +60,22 @@ impl ResponseError for Error { Self::NotFound(msg) => { HttpResponse::NotFound().json(ErrorInformation::new("Not Found", msg)) } - Error::Ingestor(inner) => { - HttpResponse::BadRequest().json(ErrorInformation::new("Ingestor error", inner)) - } - Error::Query(err) => { + Self::Ingestor(inner) => inner.error_response(), + Self::Query(err) => { HttpResponse::BadRequest().json(ErrorInformation::new("Query error", err)) } - Error::IdKey(err) => HttpResponse::BadRequest().json(ErrorInformation::new("Key", err)), - Error::StorageKey(err) => { + Self::IdKey(err) => HttpResponse::BadRequest().json(ErrorInformation::new("Key", err)), + Self::StorageKey(err) => { HttpResponse::BadRequest().json(ErrorInformation::new("Storage Key", err)) } - Error::Compression(decompress::Error::UnknownType) => { + Self::Compression(decompress::Error::UnknownType) => { HttpResponse::UnsupportedMediaType() .json(ErrorInformation::new("UnsupportedCompression", self)) } - Error::Compression(decompress::Error::PayloadTooLarge) => { + Self::Compression(decompress::Error::PayloadTooLarge) => { HttpResponse::PayloadTooLarge().json(ErrorInformation::new("PayloadTooLarge", self)) } - Error::Compression(err) => { + Self::Compression(err) => { HttpResponse::BadRequest().json(ErrorInformation::new("CompressionError", err)) } diff --git a/modules/storage/Cargo.toml b/modules/storage/Cargo.toml index dc4ae4d63..ed52769ef 100644 --- a/modules/storage/Cargo.toml +++ b/modules/storage/Cargo.toml @@ -22,6 +22,7 @@ tempfile = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } tokio-util = { workspace = true, features = ["full"] } +tracing = { workspace = true } [dev-dependencies] rstest = { workspace = true } diff --git a/modules/storage/src/service/fs.rs b/modules/storage/src/service/fs.rs index b98a04f0d..e95e33ade 100644 --- a/modules/storage/src/service/fs.rs +++ b/modules/storage/src/service/fs.rs @@ -17,6 +17,7 @@ use tokio::{ io::AsyncWriteExt, }; use tokio_util::io::ReaderStream; +use tracing::instrument; /// A filesystem backed store /// @@ -98,6 +99,7 @@ impl FileSystemBackend { impl StorageBackend for FileSystemBackend { type Error = std::io::Error; + #[instrument(skip(stream), err(Debug, level=tracing::Level::INFO))] async fn store(&self, stream: S) -> Result> where E: Debug, diff --git a/modules/storage/src/service/s3.rs b/modules/storage/src/service/s3.rs index 5e8d75842..21b36a0ef 100644 --- a/modules/storage/src/service/s3.rs +++ b/modules/storage/src/service/s3.rs @@ -11,6 +11,7 @@ use http::{header::CONTENT_ENCODING, HeaderMap, HeaderValue}; use s3::{creds::Credentials, error::S3Error, Bucket}; use std::{fmt::Debug, io, pin::pin, str::FromStr}; use tokio_util::io::{ReaderStream, StreamReader}; +use tracing::instrument; #[derive(Clone, Debug)] pub struct S3Backend { @@ -50,6 +51,7 @@ impl S3Backend { impl StorageBackend for S3Backend { type Error = Error; + #[instrument(skip(self, stream), err(Debug, level=tracing::Level::INFO))] async fn store(&self, stream: S) -> Result> where E: Debug,