← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1989361] Re: extension using collection_actions and collection_methods with path_prefix doesn't get proper URLs

 

Looking a little more into it, the tests [0] actually always have a "/"
prefix in their "path_prefix", which works fine, because the "routes"
library calls "stripslashes()" in the "resource()" call and thus we
shouldn't end up with double-slashes.

[0]
https://github.com/sapcc/neutron/blob/64bef10cd97d1f56647a4d20a7ce0644c18b8ece/neutron/tests/unit/api/test_extensions.py#L237

** Changed in: neutron
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1989361

Title:
  extension using collection_actions and collection_methods with
  path_prefix doesn't get proper URLs

Status in neutron:
  Invalid

Bug description:
  We're creating a new extension downstream to add some special-sauce
  API endpoints. During that, we tried to use "collection_actions" to
  create some special actions for our resource. Those ended up being
  uncallable always returning a 404 as the call was interpreted as a
  standard "update" call instead of calling our special function.

  We debugged this down and it turns out the Route object created when
  registering the API endpoint in [0] ff doesn't contain a "/" at the
  start of its regexp. Therefore, it doesn't match.

  This seems to come from the fact that we - other than e.g. the
  quotasv2 extension [1] - have to set a "path_prefix".

  Looking at the underlying "routes" library, we automatically get a "/"
  prefixed for the "resource()" call [2], while the "Submap"'s
  "submapper()" call needs to already contain the prefixed "/" as
  exemplified in [3].

  Therefore, I propose to prepend a "/" to the "path_prefix" for the
  code handling "collection_actions" and "collection_methods" and will
  open a review-request for this.

  [0] https://github.com/sapcc/neutron/blob/64bef10cd97d1f56647a4d20a7ce0644c18b8ece/neutron/api/extensions.py#L159
  [1] https://github.com/sapcc/neutron/blob/64bef10cd97d1f56647a4d20a7ce0644c18b8ece/neutron/extensions/quotasv2.py#L210-L215
  [2] https://github.com/bbangert/routes/blob/main/routes/mapper.py#L1126-L1132
  [3] https://github.com/bbangert/routes/blob/main/routes/mapper.py#L78

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1989361/+subscriptions



References