500 when a Secret is Created with invalid transport key .

Bug #1554172 reported by Fernando Diaz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Barbican
Fix Released
Undecided
Elvin Tubillara

Bug Description

When a transport key is not found when creating a Secret, a not found transport key should return a 400 Bad Request for the POST on Secrets.

vagrant@vagrant-ubuntu-ype:application/json" -H "X-Auth-Token: $TOKEN" -d '{"payload": "my-secret-here", "payload_content_type": "text/plain",
    "transport_key_needed": "true", "transport_key_id": "http://10.0.2.15:9311/v1/transport_keys/fa97878e-c2e9-4a3b-9895-b653a5997da5"}' http://localhost:9311/v1/secrets

{"code": 500, "description": "Secret creation failure seen - please contact site administrator.", "title": "Internal Server Error"}vagrant@vagrant-ubuntu-trustyype:application/json" -H "X-Auth-Token: $TOKEN" -d '{"payload": "my-secret-here", "payload_content_type": "text/plain",
    "transport_key_needed": "true", "transport_key_id": "http://10.0.2.15:9311/v1/transport_keys/fa97878e-c2e9-4a3b-9895-b653a5997da5"}' http://localhost:9311/v1/secrets
{"code": 500, "description": "Secret creation failure seen - please contact site administrator.", "title": "Internal Server Error"}

LOG:
2016-03-07 18:35:39.528 ERROR barbican.model.repositories [req-47ae5cb6-9763-47f7-9336-8841d86ee48d 7c9b51838c5f4841a09c80843baa8148 316fc8a5d7e9454f854ddd20db74c0e9] Not found for http://10.0.2.15:9311/v1/transport_keys/fa97878e-c2e9-4a3b-9895-b653a5997da5
2016-03-07 18:35:39.528 TRACE barbican.model.repositories Traceback (most recent call last):
2016-03-07 18:35:39.528 TRACE barbican.model.repositories File "/opt/stack/barbican/barbican/model/repositories.py", line 358, in get
2016-03-07 18:35:39.528 TRACE barbican.model.repositories entity = query.one()
2016-03-07 18:35:39.528 TRACE barbican.model.repositories File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2699, in one
2016-03-07 18:35:39.528 TRACE barbican.model.repositories raise orm_exc.NoResultFound("No row was found for one()")
2016-03-07 18:35:39.528 TRACE barbican.model.repositories NoResultFound: No row was found for one()
2016-03-07 18:35:39.528 TRACE barbican.model.repositories
2016-03-07 18:35:39.533 ERROR barbican.api.controllers [req-47ae5cb6-9763-47f7-9336-8841d86ee48d 7c9b51838c5f4841a09c80843baa8148 316fc8a5d7e9454f854ddd20db74c0e9] Secret creation failure seen - please contact site administrator.
2016-03-07 18:35:39.533 TRACE barbican.api.controllers Traceback (most recent call last):
2016-03-07 18:35:39.533 TRACE barbican.api.controllers File "/opt/stack/barbican/barbican/api/controllers/__init__.py", line 104, in handler
2016-03-07 18:35:39.533 TRACE barbican.api.controllers return fn(inst, *args, **kwargs)
2016-03-07 18:35:39.533 TRACE barbican.api.controllers File "/opt/stack/barbican/barbican/api/controllers/__init__.py", line 90, in enforcer
2016-03-07 18:35:39.533 TRACE barbican.api.controllers return fn(inst, *args, **kwargs)
2016-03-07 18:35:39.533 TRACE barbican.api.controllers File "/opt/stack/barbican/barbican/api/controllers/__init__.py", line 146, in content_types_enforcer
2016-03-07 18:35:39.533 TRACE barbican.api.controllers return fn(inst, *args, **kwargs)
2016-03-07 18:35:39.533 TRACE barbican.api.controllers File "/opt/stack/barbican/barbican/api/controllers/secrets.py", line 348, in on_post
2016-03-07 18:35:39.533 TRACE barbican.api.controllers transport_key_id=data.get('transport_key_id'))
2016-03-07 18:35:39.533 TRACE barbican.api.controllers File "/opt/stack/barbican/barbican/plugin/resources.py", line 87, in store_secret
2016-03-07 18:35:39.533 TRACE barbican.api.controllers transport_key_id)
2016-03-07 18:35:39.533 TRACE barbican.api.controllers File "/opt/stack/barbican/barbican/plugin/resources.py", line 51, in _get_plugin_name_and_transport_key
2016-03-07 18:35:39.533 TRACE barbican.api.controllers entity_id=transport_key_id)
2016-03-07 18:35:39.533 TRACE barbican.api.controllers File "/opt/stack/barbican/barbican/model/repositories.py", line 364, in get
2016-03-07 18:35:39.533 TRACE barbican.api.controllers _raise_entity_not_found(self._do_entity_name(), entity_id)
2016-03-07 18:35:39.533 TRACE barbican.api.controllers File "/opt/stack/barbican/barbican/model/repositories.py", line 2250, in _raise_entity_not_found
2016-03-07 18:35:39.533 TRACE barbican.api.controllers id=entity_id))
2016-03-07 18:35:39.533 TRACE barbican.api.controllers NotFound: No TransportKey found with ID http://10.0.2.15:9311/v1/transport_keys/fa97878e-c2e9-4a3b-9895-b653a5997da5
2016-03-07 18:35:39.533 TRACE barbican.api.controllers
2016-03-07 18:35:39.541 INFO barbican.api.middleware.context [req-47ae5cb6-9763-47f7-9336-8841d86ee48d 7c9b51838c5f4841a09c80843baa8148 316fc8a5d7e9454f854ddd20db74c0e9] Processed request: 500 Internal Server Error - POST http://localhost:9311/v1/secrets

Changed in barbican:
assignee: nobody → Elvin Tubillara (edtubill)
Changed in barbican:
status: New → Incomplete
status: Incomplete → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to barbican (master)

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

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

Reviewed: https://review.openstack.org/290577
Committed: https://git.openstack.org/cgit/openstack/barbican/commit/?id=caa0bd0301a9cccd4049de0fa781423cb1894372
Submitter: Jenkins
Branch: master

commit caa0bd0301a9cccd4049de0fa781423cb1894372
Author: Elvin Tubillara <email address hidden>
Date: Wed Mar 9 09:16:07 2016 -0600

    Fix 500 server error invalid transport key during secret creation

    If a user creates a secret and passes in a transport key reference
    that does not exist, the server responds to a 500 error. It has
    been fixed to return a 400 error with a message that says transport key
    not found.

    Change-Id: I3c6dd459efc4aec611f88a73b118cd3f36444b63
    Closes-Bug: #1554172

Changed in barbican:
status: In Progress → Fix Released
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/barbican 2.0.0.0rc1

This issue was fixed in the openstack/barbican 2.0.0.0rc1 release candidate.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.