Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return provider_class on provider requests #14657

Merged
merged 1 commit into from
Apr 7, 2017
Merged

Return provider_class on provider requests #14657

merged 1 commit into from
Apr 7, 2017

Conversation

jntullo
Copy link

@jntullo jntullo commented Apr 5, 2017

Before:

GET /api/providers/:id?provider_class=provider
{
   "href": "/api/providers/:id".
   "actions": [
      { "href": "/api/providers/:id" }
  ]
}

After:

GET /api/providers/:id?provider_class=provider
{
   "href": "/api/providers/:id?provider_class=provider",
    "actions": [
      { "href": "/api/providers/:id?provider_class=provider" }
  ]
}

This PR resolves the issue where the provider_class is not being appended to the hrefs returned on both the object or actions. This could cause them to perform an action on a different object or get a different object in return.

@miq-bot add_label bug, api
@miq-bot assign @abellotti

Links

@jntullo
Copy link
Author

jntullo commented Apr 5, 2017

cc: @imtayadeway

@abellotti
Copy link
Member

This might break some clients that expect the href to not include anything else (intent of our href). Is this a current issue reported ? what collection & collection_class specifically ?

clients calling our API would normally specify/add the provider_class in the URL in each request, this is how provider_class=provider for /api/providers is documented.

@miq-bot
Copy link
Member

miq-bot commented Apr 6, 2017

Checked commit jntullo@60e75da with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks good. 🏆

@jntullo
Copy link
Author

jntullo commented Apr 6, 2017

There is a BZ for this.

This will only add a suffix if ?provider_class=provider was a part of the request. If you run a get of a provider:

/api/providers/:id?provider_class=provider

The EDIT action has an href

/api/providers/:id

Which is a different object completely - or the object itself doesn't exist. Although the API client might add in the provider_class, I don't think we should send back misleading information or rely on them to do so. I can add in tests for other collections that there are concerns about breaking.

@abellotti
Copy link
Member

hmm, ok. provider_class=provider would be the only concern, others are implemented for subclass refinement, so the original /api/:collection would hold true.

we need to play with the API client with this as it uses returned href's for accessing subsequent resources.

@abellotti
Copy link
Member

Ok, I've tested this Fix with the API Client and it's a definite 👍

miq.vms.search_options(:provider_class => "provider").first.delete deleted the first Provider instance and not ExtMangementSystem. The href with the included ?provider_class was honored as is with the client while running the action.

Without this fix, the wrong provider would have been deleted.

Thanks @jntullo for fixing this 😍

@abellotti abellotti merged commit 58efc71 into ManageIQ:master Apr 7, 2017
@abellotti abellotti added this to the Sprint 58 Ending Apr 10, 2017 milestone Apr 7, 2017
simaishi pushed a commit that referenced this pull request Apr 7, 2017
Return provider_class on provider requests
(cherry picked from commit 58efc71)
@simaishi
Copy link
Contributor

simaishi commented Apr 7, 2017

Fine backport details:

$ git log -1
commit f787f5f90c4208f52d8eb2913093e1480a400fcc
Author: Alberto Bellotti <[email protected]>
Date:   Fri Apr 7 16:21:26 2017 -0400

    Merge pull request #14657 from jntullo/bz/providers_href
    
    Return provider_class on provider requests
    (cherry picked from commit 58efc71e197464eb229fe3c425f9195cdbcb5502)

@simaishi
Copy link
Contributor

simaishi commented Apr 7, 2017

@jntullo @abellotti Will it be a problem backporting this to Euwe and Darga as well (as per flags on the BZ)?

@abellotti
Copy link
Member

@simaishi I don't think it's a straight backport, the PR touches files from a refactored API source base, so those releases will need separate PRs done for them.

@simaishi
Copy link
Contributor

Backported to Euwe via #14866

@simaishi
Copy link
Contributor

simaishi commented May 3, 2017

Backported to Darga via #14874

@jntullo jntullo deleted the bz/providers_href branch November 28, 2017 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants