dropScope and dropCollection raise FeatureNotAvailableError instead of the expected {Scope|Collection}NotFoundError
Description
Environment
None
Gerrit Reviews
None
Release Notes Description
None
blocks
Activity
Show:
Brett Lawson July 30, 2021 at 6:49 PM
Hey Hakim,
This is actually a slightly different version of this problem and I have filed https://couchbasecloud.atlassian.net/browse/JSCBC-905#icft=JSCBC-905 to cover it.
Cheers, Brett
Hakim Cassimally July 26, 2021 at 2:46 PM
Hey Brett, I'm still getting this error, having run
npm install couchbase --save
and I now have couchbase@3.2.0-dev but get this error:
❯ node modules/howtos/examples/collection-manager.js
scopeAdmin
create-collection-manager
create-scope
The scope already exists
create-collection
The scope does not exist
drop-collection
ERR: FeatureNotAvailableError: feature not available
at CollectionManager.<anonymous> (/Users/hakimcassimally/couchbase/docs-sdk-nodejs/node_modules/couchbase/dist/collectionmanager.js:232:31)
at Generator.next (<anonymous>)
at fulfilled (/Users/hakimcassimally/couchbase/docs-sdk-nodejs/node_modules/couchbase/dist/collectionmanager.js:5:58) {
cause: undefined,
context: HttpErrorContext {
method: 'DELETE',
request_path: '/pools/default/buckets/travel-sample/scopes/example-scope/collections/example-collection',
response_code: 404,
response_body: '{"errors":{"_":"Scope with name \\"example-scope\\" is not found"}}'
}
}
Brett Lawson March 18, 2021 at 6:33 PM
Looks like we should be checking for explicit errors like 'not found' before we fall back to the checks for 'not supported'.
Fixed
Pinned fields
Click on the next to a field label to start pinning.
Created March 18, 2021 at 6:31 PM
Updated July 30, 2021 at 6:49 PM
Resolved July 30, 2021 at 6:49 PM
Instabug
when I
await cmgr.dropScope("nonexistent-scope")
I’m getting a FeatureNotAvailableError instead of the expected ScopeNotFoundError@Brett Lawson says "Good catch. Definitely a bug. I think I just need to invert the operations there. Detecting the explicit not-found before the feature-not-available."
if ( errText.includes('not allowed on this version of cluster') || res.statusCode === 404 ) { throw new FeatureNotAvailableError(undefined, errCtx) } if (errText.includes('not found') && errText.includes('scope')) { throw new ScopeNotFoundError(undefined, errCtx) }
The same issue applies with
await collectionMgr.dropCollection("nonexistent-collection", "example-scope");
Also note that https://github.com/couchbase/couchnode/blob/faa22141b3f24150190f50aab80dc46671d6a16c/test/collectionmanager.test.js seems to test for this, so may be worth double checking if it's run correctly.