Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG::CharacterNotInRepertoire exception #274

Open
sunny opened this issue Dec 22, 2018 · 1 comment
Open

PG::CharacterNotInRepertoire exception #274

sunny opened this issue Dec 22, 2018 · 1 comment

Comments

@sunny
Copy link

sunny commented Dec 22, 2018

Hello!

I am suddenly receiving a lot of PG::CharacterNotInRepertoire exceptions coming from chinese IPs. I don't know if this is an attempt at an attack or regular visitors. I can't seem to see in the environment variables at the time of the exception where these characters are coming from but I am guessing that this comes from either inserting the request_hash or the referer as impressions.

The full exception message:

PG::CharacterNotInRepertoire: ERROR: invalid byte sequence for encoding "UTF8": 0xe8 0x6c 0x65`: INSERT INTO "impressions" ("impressionable_type", "impressionable_id", "controller_name", "action_name", "request_hash", "ip_address", "session_hash", "referrer", "params", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING "id"

Using:

  • impressionist v1.6.1
  • rails v5.1.0
  • pg v0.18.1

So that impressionist does not stop the website from being browsed I fixed this temporarily by adding to my ApplicationController:

def impressionist(_record)
  super
rescue PG::CharacterNotInRepertoire
end

Any hints on how to fix this properly?

@grfx1985
Copy link

grfx1985 commented Jul 9, 2019

it raises ActiveRecord::StatementInvalid and the MESSAGE has the pg content

rescue => e 
  if e.message.include?("PG::CharacterNotInRepertoire") 
    do some stuff !! 
  else
    do something else / ignore 
  end 
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants