Bug #16415

api/v2/ptables accepts only wrapped hash of attributes with "layout"

Added by roman plevka 10 months ago. Updated 9 months ago.

Status:Closed
Priority:Normal
Assigned To:Shlomi Zadok
Category:API
Target version:Team Marek Iteration 3
Difficulty: Bugzilla link:
Found in release:nightly Pull request:https://github.com/theforeman/foreman/pull/3817
Story points-
Velocity based estimate-
Release1.13.0Release relationshipAuto

Description

# rpm -qa foreman
foreman-1.13.0-0.develop.201608221148git5908bf4.el7.noarch
# rpm -qa katello
katello-3.1.0-4.nightly.el7.noarch

Partition table API endpoint has changed behavior in JSON it accepts.

The payload now needs to follow jsonapi standard in order to be accepted, bringing inconsistency to api/v2:

Old (consistent) way:

# curl -ku admin:changeme -H 'Content-Type: application/json' -d '{"name":"foo1", "layout":"my_layout"}' https://katello.server.com/api/v2/ptables
{
  "error": {"id":null,"errors":{"template":["can't be blank"],"layout":["can't be blank"]},"full_messages":["Template can't be blank","Layout can't be blank"]}
}

New format:

]# curl -ku admin:changeme -H 'Content-Type: application/json' -d '{"ptable":{"name":"foo1", "layout":"my_layout"}}' https://hp-dl380pgen8-02-vm-3.lab.bos.redhat.com/api/v2/ptables
{"layout":"my_layout","os_family":null,"created_at":"2016-09-01 13:25:18 UTC","updated_at":"2016-09-01 13:25:18 UTC","name":"foo1","id":79,"operatingsystems":[],"locations":[],"organizations":[]}

Associated revisions

Revision eb9a7a49
Added by Shlomi Zadok 10 months ago

Fixes #16415 - Accept unwrapped hash with 'layout' attribute

History

#1 Updated by Dominic Cleal 10 months ago

  • Subject changed from api/v2/ptables accepts only jsonapi-formatted payload to api/v2/ptables accepts only wrapped hash of attributes
  • Difficulty deleted (trivial)

When did this change? Versus the 1.12.x release series, or a very recent nightly?

#2 Updated by Dominic Cleal 10 months ago

  • Subject changed from api/v2/ptables accepts only wrapped hash of attributes to api/v2/ptables accepts only wrapped hash of attributes with "layout"

Possibly from #7096, looks ancient to me. The "layout" attribute isn't a known wrapped attribute as it's only a model alias of "template" for pre-STI compatibility - it should be explicitly listed in the controller.

#3 Updated by The Foreman Bot 10 months ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Shlomi Zadok
  • Pull request https://github.com/theforeman/foreman/pull/3817 added

#4 Updated by Shlomi Zadok 10 months ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#5 Updated by Dominic Cleal 10 months ago

  • Release set to 1.12.3

#6 Updated by Marek Hulán 10 months ago

  • Target version set to Team Marek Iteration 3

#7 Updated by Dominic Cleal 9 months ago

  • Release changed from 1.12.3 to 1.13.0

Issue not present in 1.12-stable, probably due to wrap_parameters changing behaviour with strong params.

Also available in: Atom PDF