Bug 1770197 - Upload custom image for service catalog items via API fails.
Summary: Upload custom image for service catalog items via API fails.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.10.12
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: GA
: 5.11.7
Assignee: drew uhlmann
QA Contact: Parthvi Vala
Red Hat CloudForms Documentation
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-11-08 13:06 UTC by mheppler
Modified: 2022-07-09 11:29 UTC (History)
7 users (show)

Fixed In Version: 5.11.7.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-08-06 14:32:52 UTC
Category: Bug
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:
simaishi: cfme-5.11.z+


Attachments (Terms of Use)
tool for manipulating with service catalog item custom images (2.86 KB, text/x-python)
2019-11-08 13:29 UTC, mheppler
no flags Details
sample config for add_custom... script (106 bytes, text/plain)
2019-11-08 13:30 UTC, mheppler
no flags Details
Picture used in provided sample (3.05 KB, image/png)
2019-11-08 13:31 UTC, mheppler
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2020:3358 0 None None None 2020-08-06 14:33:04 UTC

Description mheppler 2019-11-08 13:06:12 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 mheppler 2019-11-08 13:26:21 UTC
Sorry for mess bug, saved accidentaly:


Description of problem:

When updating Service Catalog item picture via API, image is corrupted...

  POST api/service_templates/:id

with data:

  { "action": "edit",
    "resource": {
      "picture": {
        "content": "<base64 encoded picture data>",
        "extension": "png"
      }
    }
  }

give me result:

Status code: 200
Result: {
  "href": "https://10.44.130.143/api/service_templates/1000000000002",
  "name": "Test test 2",
  "id": "1000000000002",
  "picture": {
    "id": "1000000000076",
    "resource_id": "1000000000002",
    "resource_type": "ServiceTemplate",
    "extension": "png",
    "md5": "da5ae2d0b48af98af8d263c88d099ff1",
    "image_href": "https://10.44.130.143/pictures/1000000000076.png",
    "href": "https://10.44.130.143/api/pictures/1000000000076"
  }
}

This seems OK, but when I get image back via image_href, I got not image itself, but base64 encoded content. When I upload same image directly via UI, image is uploaded correctly.

Same picture uploaded via UI (74) and via API (75) discovered via rails console:

irb(main):034:0> Picture.find_each { |p| puts p.image_href; puts p.md5 }
/pictures/1000000000074.png
0a3a9b482ea341f4c7dabe6a91935cdc
/pictures/1000000000075.png
da5ae2d0b48af98af8d263c88d099ff1


Testing is based on https://www.manageiq.org/docs/reference/latest/api/reference/pictures


Version-Release number of selected component (if applicable):

5.10.12


How reproducible:

Upload image via API.


Steps to Reproduce:
1. 
2.
3.

Actual results:

Image uploaded via API is corrupted


Expected results:

Correct image uploaded via API


Additional info:

python tool for image manipulation and sample image provided...

Comment 3 mheppler 2019-11-08 13:29:31 UTC
Created attachment 1634003 [details]
tool for manipulating with service catalog item custom images

sample usage:

./add_picture_to_service_teplates.py -H server -u user -p password -c example.yml

Comment 4 mheppler 2019-11-08 13:30:21 UTC
Created attachment 1634004 [details]
sample config for add_custom... script

Comment 5 mheppler 2019-11-08 13:31:00 UTC
Created attachment 1634005 [details]
Picture used in provided sample

Comment 6 drew uhlmann 2020-03-16 19:05:19 UTC
Interesting. We have the create_resource method on https://github.com/ManageIQ/manageiq-api/commit/a094fc43716f1ae20cdf11fe1791d81359a8405e#diff-1ed2364c54258538ea18b6583cd23245R3 which doesn't seem to be running at all, which from the specs however does appear to be working fine (the md5 generated looks correct).

Comment 7 Satoe Imaishi 2020-03-20 19:53:11 UTC
https://github.com/ManageIQ/manageiq-api/pull/777

Comment 8 CFME Bot 2020-03-20 19:56:18 UTC
New commit detected on ManageIQ/manageiq-api/jansa:

https://github.com/ManageIQ/manageiq-api/commit/dca8f395455a25f208e27122156e832dbea0b0ef
commit dca8f395455a25f208e27122156e832dbea0b0ef
Author:     Brandon Dunne <bdunne>
AuthorDate: Tue Mar 17 16:54:35 2020 +0000
Commit:     Brandon Dunne <bdunne>
CommitDate: Tue Mar 17 16:54:35 2020 +0000

    Merge pull request #777 from d-m-u/add_spec_for_service_template_picture_update_encoding

    force updated service template photo encoding

    (cherry picked from commit 57f889ebd3503bc65e27e5c50bf42d525d209516)

    https://bugzilla.redhat.com/show_bug.cgi?id=1770197

 app/controllers/api/service_templates_controller.rb | 5 +
 spec/requests/service_templates_spec.rb | 19 +
 2 files changed, 24 insertions(+)

Comment 9 CFME Bot 2020-06-18 20:46:24 UTC
New commit detected on ManageIQ/manageiq-api/ivanchuk:

https://github.com/ManageIQ/manageiq-api/commit/7237c8a65c9414525f3f49334e141b6903ddc524
commit 7237c8a65c9414525f3f49334e141b6903ddc524
Author:     Brandon Dunne <bdunne>
AuthorDate: Tue Mar 17 16:54:35 2020 +0000
Commit:     Satoe Imaishi <simaishi>
CommitDate: Thu Jun 18 20:44:32 2020 +0000

    Merge pull request #777 from d-m-u/add_spec_for_service_template_picture_update_encoding

    force updated service template photo encoding

    (cherry picked from commit 57f889ebd3503bc65e27e5c50bf42d525d209516)

    https://bugzilla.redhat.com/show_bug.cgi?id=1770197

 app/controllers/api/service_templates_controller.rb | 5 +
 spec/requests/service_templates_spec.rb | 19 +
 2 files changed, 24 insertions(+)

Comment 10 Parthvi Vala 2020-07-27 08:21:13 UTC
FIXED. Verified on 5.11.7.2.

Steps taken to verify - 
1. Create a service template.
2. Edit the service template by uploading a picture.
POST /api/service_templates/:id

{'action': 'edit', 'resource': {'picture': {'content': 'iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAASRJREFUeNrs2dENgjAQBmA0vuMmOgJOwAidxUk6Am5QNkA3cQPsQ00MOWivubZXvD/5n6yEL6UUtGkkEknptK7VIybXtnbE7FolZomoErOGSIo5JECMtlfPuKdtZ/vwjLtxnAloZnxjWCGU6xxRVohvFGdIKCIWwwqx3NkVJwgGAe3sigMEi1jbP1RJSCwiFsMSEYNpuSKwGNLHGWpEEUwqRFYM5ZqYSmGoEKGPKEkwVAgDHDvrzFCtCQhiCNeMN5pwYfc/3+sJbwA69PLShHcnEzATGIzGLngNPIoPkS9IMR2AVwBNtTmajBCDObHjXn7O3A3klOi4oyuUzrUayH3j804uLYEIRCACEYhABPIHEOx/iBfbc6Zze9u+GolEQpKPAAMA4izw+Y/OTcoAAAAASUVORK5CYII=', 'extension': 'png'}}}

3. Query the image_href -
GET /api/service_templates/2?attributes=picture.image_href

4. Check if the image is accessible by the image_href received in step 3

Comment 13 errata-xmlrpc 2020-08-06 14:32:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Critical: CloudForms 5.0.7 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:3358


Note You need to log in before you can comment on or make changes to this bug.