Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
httpd: Fix error status code on project not found
cloudhead committed 2 years ago
commit 1a81c704bc8fa2f20539a321238e290c8bd9592a
parent 3ddec3dd7dc3dcf74ef826024f54c3023ad1e0b9
2 files changed +10 -0
modified radicle-httpd/src/api/error.rs
@@ -97,6 +97,7 @@ impl IntoResponse for Error {
                StatusCode::INTERNAL_SERVER_ERROR,
                Some(e.message().to_owned()),
            ),
+
            Error::Storage(err) if err.is_not_found() => (StatusCode::NOT_FOUND, None),
            Error::BadRequest(msg) => (StatusCode::BAD_REQUEST, Some(msg)),
            other => {
                tracing::error!("Error: {message}");
modified radicle-httpd/src/api/v1/projects.rs
@@ -837,6 +837,15 @@ mod routes {
    }

    #[tokio::test]
+
    async fn test_projects_not_found() {
+
        let tmp = tempfile::tempdir().unwrap();
+
        let app = super::router(seed(tmp.path()));
+
        let response = get(&app, "/projects/rad:z2u2CP3ZJzB7ZqE8jHrau19yjcfCQ").await;
+

+
        assert_eq!(response.status(), StatusCode::NOT_FOUND);
+
    }
+

+
    #[tokio::test]
    async fn test_projects_commits_root() {
        let tmp = tempfile::tempdir().unwrap();
        let app = super::router(seed(tmp.path()));