piece-retriever: add try different SP on retrieval failure#438
piece-retriever: add try different SP on retrieval failure#438juliangruber merged 11 commits intomainfrom
Conversation
| const response = new Response('No retrieval candidate found', { | ||
| status: 404, | ||
| }) | ||
| setContentSecurityPolicy(response) |
There was a problem hiding this comment.
I would like to better understand why we cannot use httpAssert here. Can you please explain?
I am also concerned about the error message "No retrieval candidate found" - from the perspective of a retrieval client, it's not clear to me how to troubleshoot this error.
There was a problem hiding this comment.
See code below, with http assert we can't add the content security policy.
I am also concerned about the error message "No retrieval candidate found" - from the perspective of a retrieval client, it's not clear to me how to troubleshoot this error.
Do you have a suggestion? Tbh I don't know if this case can even ever happen, since this is after all of those checks in
worker/piece-retriever/lib/store.js
Lines 133 to 207 in e568131
There was a problem hiding this comment.
Why do we need a content security policy for a 404 response with a text body? We are currently not setting up the content security policy in this case, as far as I can tell from the code. What changed?
Alternatively, is there a reason why we should not set CSP for every execution path? We can move the call of setContentSecurityPolicy to the fetch function above, which is a thin wrapper around the real request handler that adds error handling for HTTP asserts.
I am also concerned about the error message "No retrieval candidate found" - from the perspective of a retrieval client, it's not clear to me how to troubleshoot this error.
Do you have a suggestion? Tbh I don't know if this case can even ever happen, since this is after all of those checks in
So before this change, the error message mentioned the service provider that we are refusing to cache-miss to.
When I look at getRetrievalCandidatesAndValidatePayer, there is a check before returning the filtered array to ensure there is at least one candidate left, so I agree with you that this error will never happen in the current codebase.
I propose to rephrase the error message to something like the following:
Internal error: No available provider was found for cache-miss request Piece CID ${pieceCid} and Payer ${payerWalletAddress}I am struggling to find a good way to describe the fact that this is not only about finding an SP willing to serve the content, but also about the client having a payment rail with non-zero remaining cache-miss egress remaining. I.e. we want a generic message saying that our internal provider discovery mechanism failed in an unexpected way.
How about this:
Internal error: service provider lookup failed.
I think we should also return status code 500 for Internal Server Error.
Thoughts?
Co-authored-by: Miroslav Bajtoš <oss@bajtos.net>
Co-authored-by: Miroslav Bajtoš <oss@bajtos.net>
| ) | ||
| const response = new Response( | ||
| `Service provider ${serviceProviderId} is unavailable${retrievalResult ? ` at ${retrievalResult.url}` : ''}`, | ||
| `No available service provider found. Attempted: ${retrievalAttempts.map((a) => `ID=${a.serviceProviderId} (Service URL=${a.serviceUrl})`).join(', ')}`, |
There was a problem hiding this comment.
We will eventually need to update filbeam-bot to support an array of IDs in this header:
https://github.com/filbeam/bot/blob/c4479005a7834e0e708d1dc910bc9fd4baf5794a/index.js#L197-L203
Maybe after we land my PR filbeam/bot#40 first, to avoid merge conflicts.
No description provided.