Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed Jan 15, 2025
1 parent 8be1bb7 commit ad80f63
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions catalyst-gateway/bin/src/service/api/documents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ impl DocumentApi {
)]
async fn put_document(
&self, /// The document to PUT
cbor: Cbor,
document: Cbor,
/// Authorization required.
_auth: NoneOrRBAC,
) -> put_document::AllResponses {
match cbor.into_bytes_with_limit(MAXIMUM_DOCUMENT_SIZE).await {
match document.into_bytes_with_limit(MAXIMUM_DOCUMENT_SIZE).await {
Ok(doc_bytes) => put_document::endpoint(doc_bytes).await,
Err(ReadBodyError::PayloadTooLarge) => put_document::Responses::PayloadTooLarge.into(),
Err(e) => {
put_document::Responses::BadRequest(Json(PutDocumentBadRequest::new(format!(
put_document::Responses::BadRequest(Json(PutDocumentBadRequest::new(&format!(
"Failed to read document from the request, err: {e}"
))))
.into()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ pub(crate) struct PutDocumentBadRequest {
/// Error messages.
#[oai(validator(max_length = "100", pattern = "^[0-9a-zA-Z].*$"))]
error: String,
// TODO: Add optional verbose error fields for documents that fail validation.
}

impl PutDocumentBadRequest {
/// Create a new instance of `ConfigBadRequest`.
pub(crate) fn new(error: impl ToString) -> Self {
pub(crate) fn new(error: &impl ToString) -> Self {
Self {
error: error.to_string(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ pub(crate) async fn endpoint(doc_bytes: Vec<u8>) -> AllResponses {
Err(err) => AllResponses::handle_error(&err),
}
},
Err(e) => Responses::BadRequest(Json(PutDocumentBadRequest::new(e.to_string()))).into(),
Err(e) => Responses::BadRequest(Json(PutDocumentBadRequest::new(&e))).into(),
}
}

0 comments on commit ad80f63

Please sign in to comment.