Images not resizing

Hi folks,

I am fairly new to ruby, and Sharetribe. However, my installation seems to be fairly successful. The only issue I really have is when large images are uploaded, they just fail (Image uploading failed). I am not sure what information is needed. I am using version 6.4.0; and I do have a process running “rake jobs:work”.

What am I missing here?

Thanks!

Hi @sbash,

You could look for a little more information from two places:

  1. Worker logs: there might be some indication what happens, and error trace or something similar
  2. Database and delayed_jobs table: The failed jobs should have last_error field set and that might provide you more information.

Happy hunting!

Thanks for the response.

The database I can check easily; and will do so shortly. However I cannot seem to find the worker logs, where are they? If they are supposed to be in logs/ then either the logs are not there, or there is no meaningful information being logged while the image is uploaded (i.e. tail -f logs/* does not show anything new when I upload an image)…

Thanks!

There are no errors in the delayed_job table from the last week or so.

It depends on how you have set up the system, but by default, they end up in standard out. So, the delayed_job logs should be visible in the console window where you have started the worker.

However, from your description the problem might be that the server you are using is by default ignoring large files, then these would end up in the server logs… Application logs might also give you a hint where to look for the cause.

Without anything else to go with, it’s a little difficult to say where the problem is.

Oh, perfect, thanks… Here is the error text:

Command :: PATH=/usr/bin/:$PATH; file -b --mime ‘/tmp/71dd85839ce5d7fd6d8e06ed4837c19820170824-9092-jctapx.png’
{“method”:“POST”,“path”:“/en/listing_images/add_from_file”,“format”:“text”,“controller”:“ListingImagesController”,“action”:“add_from_file”,“status”:500,“error”:“Encoding::UndefinedConversionError: "\x89" from ASCII-8BIT to UTF-8”,“duration”:65.05,“view”:0.0,“db”:1.71,“params”:{“Content-Type”:“image/png”,“listing_image”:“[FILTERED]”,“locale”:“en”},“host”:“www.communitycorals.com”,“community_id”:1,“current_user_id”:“irTzLY6M5ceOHd99_f9bkw”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36”,“referer”:“http://www.communitycorals.com/en/listings/new",“forwarded_for”:“99.241.8.146”,“request_uuid”:"3ed8be0f-7a7a-42e9-a09c-f79109acd099”}

Encoding::UndefinedConversionError (“\x89” from ASCII-8BIT to UTF-8):

lib/sharetribe_logger.rb:26:in error' app/controllers/listing_images_controller.rb:107:in new_image’
app/controllers/listing_images_controller.rb:88:in add_image' app/controllers/listing_images_controller.rb:52:in add_from_file’
lib/rack_middleware/session_context_middleware.rb:15:in call' lib/rack_middleware/marketplace_lookup.rb:33:in call’
lib/rack_middleware/custom_cookie_renamer.rb:11:in call' lib/rack_middleware/enforce_ssl.rb:23:in call’
lib/rack_middleware/health_check.rb:12:in `call’
{“method”:“POST”,“path”:“/500”,“format”:“text”,“controller”:“ErrorsController”,“action”:“not_found”,“status”:404,“duration”:4.54,“view”:1.14,“db”:0.93,“params”:{“Content-Type”:“image/png”,“listing_image”:“[FILTERED]”,“locale”:“en”,“path”:“500”},“host”:null,“community_id”:null,“current_user_id”:null,“user_agent”:null,“referer”:null,“forwarded_for”:null,“request_uuid”:null}
127.0.0.1 - - [24/Aug/2017:12:56:22 EDT] “POST /en/listing_images/add_from_file HTTP/1.1” 404 763
http://www.communitycorals.com/en/listings/new → /en/listing_images/add_from_file

Any thoughts?

The error is clearly:

Encoding::UndefinedConversionError ("\x89" from ASCII-8BIT to UTF-8):

Unfortunately, I don’t have an idea what might cause this. I would start looking for the error next by asking following questions:

  1. What’s the difference between successfully uploaded images and the failing one?
  2. Are there some changes to the default 6.4.0 code and might some of those have caused this?
  3. Is there something in the system where I run this that might cause this? (System wide configurations like encodings and so on…)

Hopefully, you are able to pinpoint the problem.

Also, 7.0.0 is running with newer Rails so upgrading to that might be beneficial at some point.

Thanks for your help so far :smile:
Well, to go through your questions…

  1. Size (i.e. if I resize the test image, it works fine)
  2. No, this is a fairly stock install. The only changes I made are in the config files.
  3. Possibly, but in researching this issue I cannot find anything that points to the system itself, it seems to be potentially bad code (hence your question 2), or a gem which is either not current, or too current…

As for 7.0, when was it released? I clones this from git in late July…

Either way, I am reproducing this installation in my dev lab; that should give me more flexibility to poke and prod at it :smile: I also submitted the issue to the Git repo, hopefully that unveils something. I will update this issue accordingly as I make progress…

I tried to reproduce this based on the information you provided in Github and couldn’t. For me, the image upload is working perfectly.

One last question that I have, is that, is that the whole stacktrace? It seems that the error is produced from sharetribe_logger.rb line 26 which is inside the method error:

  def error(msg, type = nil, structured = nil)
    @log_target.error(
      include_metadata(to_hash(msg, type, structured)).to_json)
  end

This is in turn called from the line 107 in listing_images_controller.rb:

      logger.error("Saving listing image failed", :saving_listing_image_failed, params: params, errors: listing_image.errors.messages)

So, it seems that the problem is actually that the listing image saving fails for some reason and the error contains data that can’t be converted to JSON.

If you have complete access to your system, you could try debugging this by adding the following to line 106 in listing_images_controller.rb:

binding.pry

Then create the listing normally. The above line will halt the program and open a debugging session (in the console you are running the server) where you can poke around and see what’s inside the listing.images.errors (more info e.g. here http://www.jackkinsella.ie/articles/debugging-rails-with-pry-debugger). If you can’t use binding.pry, circumventing the logger.error call and just printing the errors might also help.

Furthermore, concerning your question about 7.0.0. It was released on 8th of August. You can follow the announcements forum for releases: https://www.sharetribe.com/community/c/os-announcements

Thanks for staying on this with me…

That is the entire trace. Could this be a permissions issue? what directories does it need write access to outside of the /sharetribe directory and /tmp

More specifically, are there permissions I can check inside the /sharetribe?

So, if you cannot reproduce the problem, then we can rule out a code issue (which was a safe assumption anyway). From similar errors other folks have had, this could be a result in a gem versioning issue. Now, I am not terribly familiar with ruby and gems; but could that be the case? Can we tell which gems are responsible for interacting with the images? (or is that not a thing? lol)…

For what it is worth, I was able to reproduce the issue on another system. I installed Ubuntu 16.04 from scratch, copied the sharetribe directory from the main system and installed everything else fresh.

I will look at the debugging information you posted…

Thanks again!

Wow, that binding.pry trick sure helped…

When I first set the system up, I dropped a zero from the “max_image_filesize: 104857600” thinking 100mb was ridiculously too large (not really understanding how the image processing worked)…

Also, my test image was about 12MB, which is why I did not notice it until a user reported it (I crop and resize all my images)…

Thanks a lot for your help, I learned quite a bit from this experience :smile:

We can consider this matter closed!

Great to hear that this is resolved!