cbimport sample data not restored if sample bucket given a different name

Description

cbimport sample will fail if a different bucket name is given to the one expected in the queries. This will cause non of the data to be imported.

To avoid this in the sample format instead of having the bucket in the queries it will have the string @BUCKET_NAME@ then the sample importer will replace this string with the target bucket. We do not have to worry about N1QL injection as the bucket name will always be surronded by `` which means anything there is treated as a literal and as the bucket has to exist it means the name can only contain:

A bucket name can only contain characters in the ranges of A-Z, a-z, and 0-9; with the addition of the underscore, period, dash and percent characters; and can be no more than 100 characters in length.

Components

Affects versions

Fix versions

Labels

Environment

None

Link to Log File, atop/blg, CBCollectInfo, Core dump

None

Release Notes Description

None

Activity

Show:

Jake Rawsthorne [X] January 14, 2021 at 1:59 PM

Verified 7.0.0-2792 vs 7.0.0-4170 by creating a bucket called sampletest and running ./cbimport json -f sample -c localhost -u Administrator -p password -b sampletest -d file://../samples/travel-sample.zip from /opt/couchbase/bin

On 2792 I get:

JSON import failed: 0 documents were imported, 0 documents failed to be imported
JSON import failed: [12003] Keyspace not found in CB datastore: default:travel-sample - cause: No bucket named travel-sample

On 4170 I get:

JSON `file://../samples/travel-sample.zip` imported to `localhost` successfully
Documents imported: 63182 Documents failed: 0

CB robot November 19, 2020 at 10:06 AM

Build couchbase-server-7.0.0-3796 contains docloader commit 545d841 with commit message:
Don't hardcode bucket names in N1QL queries

CB robot November 19, 2020 at 10:06 AM

Build couchbase-server-7.0.0-3796 contains backup commit 666a013 with commit message:
Replace template bucket name in sample queries

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Is this a Regression?

Unknown

Triage

Untriaged

Story Points

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created November 18, 2020 at 12:12 PM
Updated June 17, 2021 at 10:29 PM
Resolved November 19, 2020 at 9:40 AM
Instabug