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

Remove "struct" from REST responses that will be json encoded

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Unknown

    Description

      MB-40256 is an example where the removal of "struct" from some of the REST responses (via http://review.couchbase.org/c/ns_server/+/131124) leads to failure during menelaus_util:strip_json_struct() processing.

      Slack chat...

      Steve Watanabe
      When "struct" was removed from some of the generated json responses to REST requests was there a change such that menelaus_util:encode_json() would throw an error if it saw "struct"?
       
      Artem Stemkovski 
      No. It still tolerates struct
       
      The error will be thrown if you have structure like this: {[{key, {struct, [{subkey, val}]}]}
      because :
       
      (n_0@127.0.0.1)1> menelaus_util:strip_json_struct({[{key, {struct, [{subkey, val}]}}]}).
      {[{key,{struct,[{subkey,val}]}}]}
      (n_0@127.0.0.1)2> menelaus_util:strip_json_struct({struct, [{key, {struct, [{subkey, val}]}}]}).
      {[{key,{[{subkey,val}]}}]}
      (n_0@127.0.0.1)3> menelaus_util:strip_json_struct({struct, [{key, {[{subkey, val}]}}]}).     
      {[{key,{[{subkey,val}]}}]}
       
      Steve Watanabe  
      It doesn't like this:
      {[{name,<<"default">>},
        {autoCompactionSettings,
            {struct,
                [{parallelDBAndViewCompaction,false},
                 {databaseFragmentationThreshold,
                     {struct,[{percentage,steve},{size,steve}]}},
                 {viewFragmentationThreshold,
                     {struct,[{percentage,steve},{size,steve}]}}]}},
        {purgeInterval,3},
        {saslPassword,<<"022c4e704a4467a39ac42833c3ec5aee">>}]}
       
      Artem Stemkovski 
      yep. because in order for struct to be removes the whole structure should start from struct
      see menelaus_util:strip_json_struct code
       
      Steve Watanabe  
      Should we remove "struct" from all the responses?  Is it ever required?
       
      Artem Stemkovski  
      eventually we should remove struct from code everywhere
       
      Steve Watanabe 
      ok, I'll fix this specific bug and then open a ticket to track the removal every where else.
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            steve.watanabe Steve Watanabe
            steve.watanabe Steve Watanabe
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty