One gateway call: list the sandbox's draft chunks and find the matching id. Returns `Ok(None)` only when the gateway responded successfully but no chunk in this sandbox matches.
(
session: &LookupSession<'_>,
chunk_id: &str,
)
| 927 | /// id. Returns `Ok(None)` only when the gateway responded successfully but |
| 928 | /// no chunk in this sandbox matches. |
| 929 | async fn fetch_chunk( |
| 930 | session: &LookupSession<'_>, |
| 931 | chunk_id: &str, |
| 932 | ) -> std::result::Result<Option<PolicyChunk>, (u16, serde_json::Value)> { |
| 933 | let chunks = session |
| 934 | .client |
| 935 | .get_draft_policy(session.sandbox_name, "") |
| 936 | .await |
| 937 | .map_err(|e| (502, error_payload("gateway_lookup_failed", e.to_string())))?; |
| 938 | Ok(chunks.into_iter().find(|c| c.id == chunk_id)) |
| 939 | } |
| 940 | |
| 941 | fn proposal_chunks_from_body(body: &[u8]) -> std::result::Result<Vec<PolicyChunk>, String> { |
| 942 | let request: ProposalRequest = serde_json::from_slice(body).map_err(|e| e.to_string())?; |
no test coverage detected