Quantcast
Channel: Mobile - Couchbase Forums
Viewing all articles
Browse latest Browse all 1117

Unable to include sync and import filter functions using backticks and initialize a sync gateway database

$
0
0

I am trying to use the following file for creating a sync gateway database. It is a variation of the example in the official documentation.

{
  "name": "db",
  "bucket": "bucket",
  "scopes": {
    "_default": {
      "collections": {
        "content": {
          "sync": `
              function(doc, oldDoc, meta) {
                  channel(doc.module_identifier)
              }
          `,
          "import_filter": `
            function(doc) {
              return true;
            }
          `
        }
      }
    }
  },
  "num_index_replicas": 0
}

I am basically adding the functions to the collection content in _default scope.

It gives the following error (command run is included in the code block below):

curl -v --location --request PUT 'localhost:4985/main/' --header 'Content-Type: application/json' --header 'Authorization: Basic <auth-token>' --data-raw $(cat sg-create-db-test-1.json)
*   Trying 127.0.0.1:4985...
* Connected to localhost (127.0.0.1) port 4985 (#0)
> PUT /main/ HTTP/1.1
> Host: localhost:4985
> User-Agent: curl/8.1.2
> Accept: */*
> Content-Type: application/json
> Authorization: Basic c3luY19nYXRld2F5OnBhc3N3b3Jk
> Content-Length: 1
>
< HTTP/1.1 500 Internal Server Error
< Content-Type: application/json
< Server: Couchbase Sync Gateway/3.1.1 CE
< Date: Mon, 23 Oct 2023 07:43:09 GMT
< Content-Length: 80
<
* Connection #0 to host localhost left intact
{"error":"Internal Server Error","reason":"Unable to read body: unexpected EOF"}* URL rejected: Port number was not a decimal number between 0 and 65535
* Closing connection -1
curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
* URL rejected: Bad hostname
* Closing connection -1
curl: (3) URL rejected: Bad hostname
* URL rejected: Port number was not a decimal number between 0 and 65535
* Closing connection -1
curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
* URL rejected: Bad hostname
* Closing connection -1
curl: (3) URL rejected: Bad hostname
* URL rejected: Port number was not a decimal number between 0 and 65535
* Closing connection -1
curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535
curl: (3) unmatched brace in URL position 1:
{
 ^

Here are the environment details:

  • couchbase/server:community-7.2.2
  • couchbase/sync-gateway:3.1.1-community
  • macOS Sonoma 14.0
  • curl 8.1.2 (x86_64-apple-darwin23.0) libcurl/8.1.2 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.55.1
  • all are docker images

I also tried removing the backticks and having the functions in a single line enclosed in double quotes. That didn’t work either.

I am guessing that this is a minor issue in one of my environment setup.

Any help would be appreciated. Thanks in advance.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1117

Trending Articles