Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-55205

[Export] Data written in the line format may be pretty-printed

    XMLWordPrintable

Details

    • Untriaged
    • 0
    • Yes

    Description

      Workaround
      Given we're still writing out completely valid json, the file can be pre-processed slightly before re-importing using a tool such as jq.

      $ cat test.json
      {
          "key1": "value1"
      }
      {
          "key2": "value2"
      }
      $ cat test.json | jq -c | sponge test.json
      $ cat test.json
      {"key1":"value1"}
      {"key2":"value2"}
      

      What's the issue?
      We have an optimization in cbexport which skips marshaling JSON unless required.

      This means cbimport will potentially write out valid JSON data without re-encoding it, which is fine, unless the original JSON data is pretty-printed.

      When pretty-printed, we export a multi-line JSON document in what should be the newline delimited format.

      This means documents exported by cbexport may be incompatible with cbimport when using the same lines format.

      Steps to reproduce

      1. Import the provided 'one.json' file using 'cbimport json --format list -c 172.20.1.1:8091 -u Administrator -p asdasd -d file://one.json -b beer-sample -g '#UUID#''
      2. Export the data using 'cbexport json -c 172.20.1.1 -u Administrator -p asdasd -b beer-sample -f lines -o two.json'
      3. You should see the export contains the document in pretty-printed format
      4. Repeat with the '--include-key key' flag
      5. You should see the export contains the document on one line

      What's the fix?
      We should remove this optimization (for at least the lines format).

      Attachments

        For Gerrit Dashboard: MB-55205
        # Subject Branch Project Status CR V

        Activity

          People

            james.lee James Lee
            james.lee James Lee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty