#141 API addpost call fails with a table and more than 3 metadata keys

v2.4
closed-fixed
8
2014-03-14
2014-03-02
Colin Bird
No

When using the 'addpost' API to create an entry that includes both a table and metadata, the call fails with "HTTP Error 500: Received XML did not parse" when four or more metadata keys are included with the table.
The call succeeds when four (or even seven) keys are included without a table; the call also succeeds when only three keys are included, with or without a table.
I have a set of four python programs that illustrate this problem: the entries for the successful calls can be viewed in the http://aurora.labtrove.org/colin_sandpit notebook.

Discussion

  • Tim Parkinson
    Tim Parkinson
    2014-03-02

    Dave, over to you. I suspect this is another example of some array or field not being big enough to hold whatever is being parsed.

     
  • Tim Parkinson
    Tim Parkinson
    2014-03-02

    • assigned_to: David R Newman
     
  • Tim Parkinson
    Tim Parkinson
    2014-03-02

    Colin, can you attach your Python scripts to this ticket?

     
  • Tim Parkinson
    Tim Parkinson
    2014-03-03

    Just an observation.

    The attached scripts all perform url encoding by hand (function 'encode') instead of using the library functions urllib.urlencode or urllib.quote or urllib.quote_plus. (Why?)
    Are we sure that the strings are being fully and correctly encoded?

     
    • Colin Bird
      Colin Bird
      2014-03-04

      The use of the 'replace' option dates back about 15 months, when I was in Edinburgh working with Mike Mineter. My thought was that LabTrove had failed to parse a string generated urllib.urlencode(), but that recollection was vague so I asked Mike. His reply said: "I think it was just that the string could not be parsed at one end of the internet or the other, without repeating it I'd not recall what went wrong!"

      The other angle is that I made the four python programs as near identical to each other, allowing only for the variations necessary to create the four different examples. Three of them work and one doesn't, the only difference being the quantity of xml (the length of the string) rather that the quality. Tim's observation is perfectly reasonable, though, and I would prefer to dispense with my bespoke 'encode' function, as it has grown since those early days.

      I'll give urllib.urlencode() another go sometime soon - Colin

      ---- TSP - snipped historic e-mail trail

       
      Last edit: Tim Parkinson 2014-03-04
  • Tim Parkinson
    Tim Parkinson
    2014-03-05

    • Group: For Review --> v2.4
    • Priority: 5 --> 8
     
  • David R Newman
    David R Newman
    2014-03-14

    I have just tested all four scripts with an local instance of LabTrove, I am running that is the same version of LabTrove as aurora. I had no problems running any of you scripts after adjusting them to use my credentials and LabTrove instance.

    I then tried to repeat these tests on aurora.labtrove.org and could only get those posts without tables to successfully post. This suggests there is something wrong with the table syntax but I cannot understand why my instance would not have this problem and your attempts on aurora would succeed with three keys but not with four or more.

    I will continue to investigate.

     
  • David R Newman
    David R Newman
    2014-03-14

    The issue was that the php5-suhosin has a config file that limits the size of any parameter value in the query string to 512 characters. This is clearly not sufficient for the purposes of the API. I have upped this to 8192, which I think should be long enough for almost all posts we could ever envisage.

    However, it is a reminder that we really should implement and properly RESTful API. As if this data is sent as a POST the upper limit is orders magnitude higher than it is currently.

     
  • David R Newman
    David R Newman
    2014-03-14

    • status: open --> closed-fixed
     
  • David R Newman
    David R Newman
    2014-03-14

    This should now work for all but the longest posts. So the ticket can be closed.