Skip to content

Commit

Permalink
fix: QuoteCheck saving with wrong encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasleger committed Feb 7, 2025
1 parent 4d1e33a commit 0a6df3c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/services/quote_check_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,22 @@ def read_quote(llm: nil)
category: "file",
type: "error")
ensure
# TODO: Better fix me
# Avoid null bytes inside text field for PostgreSQL
text = quote_reader.text
anonymised_text = quote_reader.anonymised_text
if text.include?("\x00")
ErrorNotifier.notify(
StandardError.new("QuoteCheck #{quote_check.id} contains null bytes")
)
text = text.gsub("\x00", "")
anonymised_text = anonymised_text.gsub("\x00", "")
end

quote_check.assign_attributes(
text: quote_reader.text,
text:,

anonymised_text: quote_reader.anonymised_text,
anonymised_text:,

naive_attributes: quote_reader.naive_attributes,
naive_version: quote_reader.naive_version,
Expand Down

0 comments on commit 0a6df3c

Please sign in to comment.