[api] homedoc should return relative URIs or encode version in href-template

Bug #1245656 reported by Allele Dev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zaqar
Critical
Feilong Wang

Bug Description

This is a snippet of our current JSON homedoc:

```
      'rel/queue': {
            'href-template': '/queues/{queue_name}',
            'href-vars': {
                'queue_name': 'param/queue_name',
            },
            'hints': {
                'allow': ['GET', 'HEAD', 'PUT', 'DELETE'],
                'formats': {
                    'application/json': {},
                },
            },
```

'href-template' is currently presented as an absolute path ('/queues'...). This would leave a well-defined client to append it to the host, yielding:

host/queues/{queue_name}

Giving a 404. The correct path would be:

host/v1/queues/{queue_name}

To fix this, we need to include the "/v1" in the path, e.g.:

'href-template': '/v1/queues/{queue_name}'

Revision history for this message
Allele Dev (alleledev) wrote :

Here's some references:

1. http://www.ietf.org/rfc/rfc1808.txt (Relative Uniform Resource Locators)
2. https://github.com/openstack/marconi/blob/master/marconi/queues/transport/wsgi/v1.py (marconi v1 homedoc)

Revision history for this message
Kurt Griffiths (kgriffs) wrote :

+1 for relavant path

Kurt Griffiths (kgriffs)
Changed in marconi:
status: New → Triaged
importance: Undecided → Critical
Changed in marconi:
assignee: nobody → Cindy Pallares (cindy-pallaresq)
Revision history for this message
Kurt Griffiths (kgriffs) wrote :

Let's fix this in v1.0, as discussed in IRC.

Changed in marconi:
assignee: Cindy Pallares (cindy-pallaresq) → nobody
Revision history for this message
Kurt Griffiths (kgriffs) wrote :

Please add a test to ensure that combining:

http://marconi.example.com/v1

with, e.g.:

queues/my-queue/messages

results in:

http://marconi.example.com/v1/queues/my-queue/messages

Changed in marconi:
assignee: nobody → Francesco Vollero (fvollero)
Revision history for this message
Kurt Griffiths (kgriffs) wrote :
Revision history for this message
Sam Harwell (sam-z) wrote :

Since the URI templates are clearly presented as part of the specification, the URI templates included in the JSON Home Document have two options:

1. Use the templates provided by the specification.
2. Use templates which differ from the specification, where the service allows the user to send the request to addresses formed from either template. For example, if the JSON home documented listed GET rel/queues at the URI template "/queues{?marker,limit,detailed}", then the service needs to accept requests sent to "/queues" (formed from the JSON home document) and also needs to accept requests sent to "/v1/queues" (formed from the URI template in the specification).

Regarding the use of absolute URI paths in the templates given in the specification, a strong case can be made for allowing these to be changed to relative paths (by removing the leading /) without incrementing the version of the specification. The reason for this is as follows:

1. The specification does not currently dictate the manner in which an absolute URI is constructed from the expanded URI template.
2. Any assumption that the construction should follow RFC 3986, which in §5.2.2 describes resolution of a relative URI, is flawed due to the simple fact that URI construction from the listed templates using that RFC will always fail when used with RBAC.

Note that if the leading slash is removed from the URI templates in the Marconi specification, the Service Catalog endpoints will need to be listed with a trailing slash or URI resolution using RFC 3986 will continue to produce incorrect URIs.

Revision history for this message
Kurt Griffiths (kgriffs) wrote :

I've elaborated on the problem and proposed solution here: http://paste.openstack.org/show/53559/

Kurt Griffiths (kgriffs)
description: updated
Changed in marconi:
milestone: none → icehouse-1
Kurt Griffiths (kgriffs)
Changed in marconi:
assignee: Francesco Vollero (fvollero) → Fei Long Wang (flwang)
Feilong Wang (flwang)
Changed in marconi:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to marconi (master)

Fix proposed to branch: master
Review: https://review.openstack.org/61495

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to marconi (master)

Reviewed: https://review.openstack.org/61495
Committed: https://git.openstack.org/cgit/openstack/marconi/commit/?id=9c5bc99b5cc39d1b0e84d9a01bf62c5234ad772a
Submitter: Jenkins
Branch: master

commit 9c5bc99b5cc39d1b0e84d9a01bf62c5234ad772a
Author: Fei Long Wang <email address hidden>
Date: Thu Dec 12 00:50:40 2013 +0800

    Return relative URIs for href-template of homedoc

    Based on current implement, some href-template of homedoc
    are returning absolute path ('/queues'...). It may cause
    a 404 error because client may join a host with the path
    directly. This patch will make sure all the href-template
    start with /v1 and add unit test case to make url joining
    works well.

    Fixes bug 1245656

    Change-Id: I12059249135cdb82be7d1937cf65db5da860011b

Changed in marconi:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in marconi:
milestone: icehouse-1 → icehouse-2
Thierry Carrez (ttx)
Changed in marconi:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in marconi:
milestone: icehouse-2 → 2014.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers