prototipando / google-cloud-sdk

Automatically exported from code.google.com/p/google-cloud-sdk
1 stars 0 forks source link

Invalid MIME type: "x-pkcs12" #531

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1 - Put a .p12 file in your repository (it's a private key).
2 - gcloud app preview deploy app.yaml

What is the expected output? What do you see instead?
The app should deploy with the .p12 file.

What is the output of 'gcloud info'?
The deployment fails, looking in the logs, you can see the root cause is the 
following line:
  Uploading   ...com/26d9d1c09c438d92f51af97acdf4c041005db637.p12: 0 B/1.69 KiB    
  Invalid MIME type: "x-pkcs12"

Please provide any additional information below.
  This error gets raised in the following file / function:

  C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\third_party\apitools\base\py\utils.py:AcceptableMimeType

The above function checks to see if there is a slash in each mimetype. On 
compute engine, most mime types are determined by the mimetypes python library, 
and particularly, mimetypes.guess_type. When you run this function on a .p12 
file, it incorrectly returns ('x-pkcs12', None)
, when it should return ('application/x-pkcs12', None). This appears to be a 
bug with mimetypes, but Google should be able to work around it.

Original issue reported on code.google.com by michael....@gmail.com on 9 Feb 2016 at 10:58

GoogleCodeExporter commented 8 years ago
I should add, I ran into this issue when deploying a managed vm instance.

Original comment by michael....@gmail.com on 9 Feb 2016 at 10:58

GoogleCodeExporter commented 8 years ago
Workaround--
add the following line to skip_files in app.yaml (adding it to .dockerignore is 
not enough)
- ^(.*/)?.*p12^

Original comment by michael....@gmail.com on 9 Feb 2016 at 2:21

GoogleCodeExporter commented 8 years ago
Thanks for the report and the detailed investigation. We'll look into working 
around.

With which Python version are you experiencing this? I'm not seeing it on any 
of the Python installations I have lying around (on Linux and OS X).

    for python in ...; do $python --version; $python -c "import mimetypes; print mimetypes.guess_type('foo.p12')"; done 
    Python 2.7.6
    ('application/x-pkcs12', None)
    Python 2.6.9
    ('application/x-pkcs12', None)
    Python 2.7.10
    ('application/xpkcs12', None)

Original comment by z...@google.com on 18 Feb 2016 at 6:32