Bytes fields in named operations are depicted in WADL as links to hosted files, not just binary data fields

Bug #430073 reported by Leonard Richardson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lazr.restful
Triaged
Low
Unassigned

Bug Description

To fix bug 353805 I made lazr.restful describe binary fields in WADL as 'type="binary"', so that lazr.restfulclient would know not to run values for those fields through simplejson.dumps(). lazr.restfulclient is doing its job, but lazr.restful is not, at least not in real life. Launchpad's WADL includes the following:

<wadl:param style="query" required="true" name="data">
  <wadl:link resource_type="https://api.staging.launchpad.net/beta/#HostedFile"/>
</wadl:param>

That's the 'data' parameter to the named operation Bug.addAttachment. It should just have a 'type="binary"', but instead it's being depicted as a link to a hosted file. That's what I'd expect for a Bytes field that was published as part of an entry (such as a user's mugshot), but now what I'd expect from a named operation.

This exact case isn't tested in the existing lazr.restful trunk, but it's easy to add a test and the test shows the behavior I'd expect. Fields that would be considered "binary" in the lazr.restful web service are said to be links to external resources when they're on Launchpad.

I don't know why this is, but I think it might have something to do with the Launchpad librarian.

Revision history for this message
Leonard Richardson (leonardr) wrote : description

trying to trigger bug 423880

Revision history for this message
Leonard Richardson (leonardr) wrote : Re: Bytes fields in named operations are depicted in WADL as links to hosted files, not binary data fields

As you can see by the test file I attached to this bug, this is not a real problem. I fell prey to various problems of my own design, including out-of-date client caches and thinking staging was running a recent version when actually it's weeks out of date.

I did find two problems, but none of them are really worth fixing now. I declare this bug to be about these more minor problems.

1. The WADL actually generated by Launchpad is this:

<wadl:param style="query" required="true" name="data" type="binary">
  <wadl:link resource_type="https://api.staging.launchpad.net/beta/#HostedFile"/>
</wadl:param>

The type="binary" is good enough for lazr.restfulclient, but that resource_type is inaccurate. We shouldn't print that line for a named operation's binary parameters.

2. I was passing in my file as "content" rather than "data", and lazr.restfulclient was simplejson.dumps()ing it because "content" isn't defined as a binary parameter. In fact, it's not defined at all. So I was getting the old simplejson.dumps() error even though the WADL was correct.

Originally I thought it was desirable behavior for lazr.restfulclient to simply pass through any unrecognized parameters. But since we don't know whether or not those parameters need preprocessing, it might be better to be strict about this, to avoid mistyped parameter names like "content" instead of "data".

summary: Bytes fields in named operations are depicted in WADL as links to hosted
- files, not binary data fields
+ files, not just binary data fields
Changed in lazr.restful:
importance: Undecided → Low
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.