Nitin Kumar Nitin Kumar - 5 months ago 14
PHP Question

PHP App Engine deployment issue

I have gone through a very weird issue and unable to resolve that. Even Google team is working on it but unable to resolve so far.

I have a CSS file which was same since a long time and never altered from last 1-2 years. Now I wanted to change at one place. I changed max-width to max-height and saved. Now I was deploying the code, but it throws an exception:

11:12 AM Scanned 1500 files.
11:12 AM Scanned 2000 files.
11:12 AM Scanned 2500 files.
11:12 AM Scanned 3000 files.
11:12 AM Scanned 3500 files.
11:12 AM Scanned 4000 files.
11:12 AM Scanned 4500 files.
11:12 AM Scanned 5000 files.
11:12 AM Scanned 5500 files.
11:12 AM Cloning 2639 static files.
11:12 AM Cloned 2000 files.
11:12 AM Cloning 2916 application files.
11:12 AM Cloned 2000 files.
11:12 AM Uploading 1 files and blobs.
2014-07-29 11:12:36,450 ERROR appcfg.py:2559 An unexpected error occurred. Abort
ing.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2400, in DoUpload
self._UploadMissingFiles(missing_files, openfunc)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2538, in _UploadMissingFiles
self.blob_batcher.Flush()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 1442, in Flush
self.SendBatch()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 1401, in SendBatch
payload,
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1934: ordin
al not in range(128)
11:12 AM Rolling back the update.
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 126, in
<module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 122, in
run_file
execfile(_PATHS.script_file(script_name), globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 5334, in <module>
main(sys.argv)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 5325, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2963, in Run
self.action(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 4991, in __call__
return method()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3762, in Update
self._UpdateWithParsedAppYaml(appyaml, self.basepath)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3815, in _UpdateWithParsedAppYaml
self.UpdateVersion(rpcserver, basepath, appyaml, APP_YAML_FILENAME)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 3698, in UpdateVersion
return appversion.DoUpload(paths, openfunc)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2400, in DoUpload
self._UploadMissingFiles(missing_files, openfunc)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 2538, in _UploadMissingFiles
self.blob_batcher.Flush()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 1442, in Flush
self.SendBatch()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\ap
pcfg.py", line 1401, in SendBatch
payload,
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1934: ordin
al not in range(128)


I changed height to width again and it deploys properly. File encoding-type is UTF-8 in both cases. Any guesses or solution to this? If you need any further information, I would love to share.

Solution



Most of the time, even though you change the file encoding type to UTF-8, it doesn't recognize it. Best way is to forcefully ask appcfg.py to treat your file with UTF-8 encoding format. You can do it by changing mime_type of the file format in app.yaml like this:

- url: /(.*\.(css$))
static_files: \1
upload: (.*\.(css$))
mime_type: text/css; charset=UTF-8


By this way, your file will be treated as UTF-8 and your deployment will not fail.

Answer

Open yourfile.css, and make sure it is saved in utf-8 encoding. Depending on your text editor, you can go to Save As, and select the encoding. The error is telling you that is ascii encoded, and it found a non-ascii character at position 1934. Use your text editor to find the 1934th character, and you will see the issue. Did you copy/paste the line from the web? If so, you most likely have a non-ascii hyphen, colon, semi-colon, or quotation mark.