2

I'm running into a strange issue that is causing my Heroku workers to crash. We're using Ruby on Rails and delayed_job for background jobs. I'm passing a job to delayed_job using the Vero gem.

This is the call I make to "identify" the user to Vero:

after_save { self.identify! }

Then it puts a job in the queue that looks like this:

--- !ruby/object:Vero::Api::Workers::Users::TrackAPI
domain: https://api.getvero.com
options:
  :email: ******@gmail.com
  :data:
    :email: ******@gmail.com
    :name: ? ?
    :first_name: ?
    :last_name: ?
    :school_id: -1

The issue seems to be those question marks. I'm not sure why they are showing up there instead of a string of text. This is the error that comes up:

Psych::SyntaxError: (<unknown>): mapping keys are not allowed in this context at line 7 column 14

Unfortunately, instead of the job just failing.. it actually crashes the worker.. not allowing for another jobs to be processed.

Has anyone run into this issue in the past? How can I format the YAML in a way that it won't crash the worker?

Thanks!

criticerz
  • 3,397
  • 3
  • 23
  • 24

1 Answers1

2

Check out this user. Seems that he entered some data not accept by the encoding of the fields in the db. Are you using utf-8? If he entered utf-16 you can translitirate it in ruby to utf-8

dre-hh
  • 7,840
  • 2
  • 33
  • 44
  • Hey @dre-hh, thanks for the answer! The table settings are.. type: InnoDB, Encoding: cp1252 West European (latin1), Collation: latin1_swedish_ci. So I guess we're not using utf-8. Do you think that's the issue? – criticerz Oct 27 '14 at 22:06
  • Find the user in your db, whose`identify!` request has generated this worker. `User.find_by_email 'chuck_testa@example.com'`. Check out his name and first_name. Also check the db record. I strongly suspect, that the issue comes just from users entering names with symbols not being able to handled by cp1252. So you will have to parse the input manually. If you use UTF-8 it will be just saved as some unrecognized sign, but the whole string will not get corrupted. See http://stackoverflow.com/questions/2708958/differences-between-utf8-and-latin1 – dre-hh Oct 28 '14 at 13:56
  • I guess these question marks ���� is this `Mojibake` the stackoverflow post is mentioning – dre-hh Oct 28 '14 at 14:05
  • Thanks for your answer! I've implemented the fix. Hopefully that does it. If not, I'll mark it as unanswered again. – criticerz Oct 28 '14 at 21:45