Comment 14 for bug 1799746

Revision history for this message
Corey Bryant (corey.bryant) wrote : Re: PY3: when uploading file as secret: TypeError: a bytes-like object is required, not 'str'

Where doeas secret_dto.secret come from?

barbican/plugin/resources.py
----------------------------
from barbican.plugin.util import translations as tr

def store_secret(unencrypted_raw, content_type_raw, content_encoding,
                 secret_model, project_model,
                 transport_key_needed=False,
                 transport_key_id=None):
  ...
  unencrypted, content_type = tr.normalize_before_encryption(
      unencrypted_raw, content_type_raw, content_encoding,
      secret_model.secret_type, enforce_text_only=True)
  ...
  secret_dto = secret_store.SecretDTO(type=secret_model.secret_type,
                                      secret=unencrypted,
                                      key_spec=key_spec,
                                      content_type=content_type,
                                      transport_key=transport_key)

so secret_dto.secret = unencrypted which is set in tr.normalize_before_encryption

barbican/plugin/util/translations.py
------------------------------------
normalize_before_encryption is defined here:

https://github.com/openstack/barbican/blob/7.0.0/barbican/plugin/util/translations.py#L25

It returns:

    return b64payload, normalized_media_type

It seems that b64payload may not be correctly getting encoded for py3.