-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: store/add handler should have more helpful error when trying to invoke against space that has not had email confirmed #134
Comments
…ure with name (#391) Motivation: * implement #382 * tl;dr `space/info` now has explicit failure type for case where the ucans are valid, but the space DID is not in the db. that way when upload-api invokes `space/info` as part of its `verifyInvocation` logic, it can distinguish between an invalid invocation and a not-found space id Unblocks: * this test passing gobengo/w3protocol-test#1 * rest of storacha/w3infra#134 (comment)
released w3protocol#382 , which helps a bit. Also started PR in w3protocol-test whose CI reproduces the error of using |
This happens now, which is much more helpful:
|
…ure with name (#391) Motivation: * implement #382 * tl;dr `space/info` now has explicit failure type for case where the ucans are valid, but the space DID is not in the db. that way when upload-api invokes `space/info` as part of its `verifyInvocation` logic, it can distinguish between an invalid invocation and a not-found space id Unblocks: * this test passing gobengo/w3protocol-test#1 * rest of storacha/w3infra#134 (comment)
Reproduction Steps
iss=space aud=alice can=store/*
@web3-storage/upload
to store a blob using a ucanto http connection to access-apiExpected Behavior
uploadFile
returns a resolved promiseuploadFile
returns a rejected promise with error that the store/add invocation gets an error result indicating that the invocation was not fulfilled because the store/add nb.space had not yet been 'registered' with the access-api. e.g. in http status codes a 4xx error, e.g. 400 bad request or even 404 [space] Not FoundActual Behavior
await uploadFile(...)
throws due to an error with the underlyingstore/add
invocation being sent to upload-api. Upload-api returns the following result:Upload-api returns the following result:
add
handler. https://github.com/web3-storage/w3infra/blob/main/upload-api/service/store/add.js#L36error stdio from test case
Diagnosis
ctx.access.verifyInvocation
on thestore/add
invocationverifyInvocation
is invokingspace/info
on access-apispace/info
by looking for the space id in its db. If the db contains none (e.g. if the space has not been 'registered' by an email I think), it returns a failure result likenew Failure('Space not found.')
verifyInvocation
sees that failure and so returns falsystore/add
handler throws the error reported in actual behavior${issuer} is not delegated capability ${Store.add.can} on ${space}
when the underlying issue is that the space is not in the db (and that the capability delegations are not the issue)Proposal
store/add
service method definition should include in its result type aFailure
case that makes sense for: "I was able to make sense of your request to add something to the storage space, and according to the ucans you might have authority, but I am refusing to because the space in question is not one I am allowed to store in. Trying again won't help unless you change something about the space itself (e.g. register it with an email address using voucher protocol or provider+accounts protocol)"404 [space] not found
or507 insufficient storage
store/add
request for a space that is not in access-api db, it returns the result type for 'unable to store' and not the current vague error result type whose message mentions${issuer} is not delegated capability ${Store.add.can} on ${space}
507
result status is the most useful hereImplementation
space/info
invocations for space dids not in its db with a well-defined error result type w3up#382verifyInvocation
callsspace/info
and gets a 404 error result, it should return aSpaceNotFound
type instead of justfalse
(which might imply that the ucan proofs can't be validated, when in fact they can)verifyInvocation: (...) => boolean
with richer return typesstore/add
handler is invoked, asks access-api about it, and gets a SpaceNotFound error, thestore/add
handler should return an error indicating why the store/add could not be handledThe text was updated successfully, but these errors were encountered: