diff --git a/core/archipelago/src/api/handler/content.rs b/core/archipelago/src/api/handler/content.rs index 627983e7..abd4125f 100644 --- a/core/archipelago/src/api/handler/content.rs +++ b/core/archipelago/src/api/handler/content.rs @@ -432,6 +432,13 @@ impl ApiHandler { let catalog = content_server::load_catalog(&self.config.data_dir) .await .unwrap_or_default(); + let Some(item) = catalog.items.iter().find(|item| item.id == content_id) else { + return Ok(build_response( + StatusCode::NOT_FOUND, + "text/plain", + hyper::Body::from("Content not found"), + )); + }; if !content_server::visible_to(item, peer.as_deref(), known, owner) { return Ok(build_response( StatusCode::NOT_FOUND, @@ -439,33 +446,24 @@ impl ApiHandler { hyper::Body::from("Content not found"), )); } - let price_sats = match catalog.items.iter().find(|i| i.id == content_id) { - Some(i) => match &i.access { - content_server::AccessControl::Paid { price_sats, .. } => { - if !content_server::method_accepted(&i.access, "onchain") { - return Ok(build_response( - StatusCode::BAD_REQUEST, - "application/json", - hyper::Body::from( - r#"{"error":"The seller does not accept on-chain payment for this item"}"#, - ), - )); - } - *price_sats - } - _ => { + let price_sats = match &item.access { + content_server::AccessControl::Paid { price_sats, .. } => { + if !content_server::method_accepted(&item.access, "onchain") { return Ok(build_response( StatusCode::BAD_REQUEST, "application/json", - hyper::Body::from(r#"{"error":"Item is not paid"}"#), - )) + hyper::Body::from( + r#"{"error":"The seller does not accept on-chain payment for this item"}"#, + ), + )); } - }, - None => { + *price_sats + } + _ => { return Ok(build_response( - StatusCode::NOT_FOUND, - "text/plain", - hyper::Body::from("Content not found"), + StatusCode::BAD_REQUEST, + "application/json", + hyper::Body::from(r#"{"error":"Item is not paid"}"#), )) } }; diff --git a/scripts/test-backend-isolated.sh b/scripts/test-backend-isolated.sh index cd167559..55d0aac0 100755 --- a/scripts/test-backend-isolated.sh +++ b/scripts/test-backend-isolated.sh @@ -15,7 +15,7 @@ case "${ARCHY_TEST_PACKAGE:-archipelago}" in *) echo 'Unsupported isolated test package' >&2; exit 2 ;; esac if ! cargo test --manifest-path "$REPO/core/Cargo.toml" "${test_target[@]}" \ - --locked --no-run --message-format=json --config 'profile.test.package.archipelago.opt-level=0' > "$metadata"; then + --locked --no-run --message-format=json --config 'profile.test.package.archipelago.opt-level=0' --config 'profile.test.package.archipelago.debug=0' > "$metadata"; then python3 - "$metadata" <<'PYDIAG' import json,sys for line in open(sys.argv[1]):