Skip to content

fix Encoding::CompatibilityError #12

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nikukyugamer
Copy link

@nikukyugamer nikukyugamer commented Jul 24, 2018

first of all, this fix is for very rare case :(

under below conditions, e.message can't be encoded correctly.

  • for example, the type of target field of e.message (it's #{name}) is numerical
  • but the value of the field contains string
    • yeah, it's amazing but can be applied by FileMaker Script
    • the character (string) was Japanese in my case and I guess it's important
  • in this case e.message causes error as below
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
from /home/takiya/foobar/vendor/bundle/ruby/2.5.0/gems/filemaker-1.0.0/lib/filemaker/metadata/field.rb:82:in `rescue in raw_cast'

to fix it, I append force_encoding method :)

note: although executing on console directly no error occurs, on the other hand by cron executing error occurs

@mech
Copy link
Owner

mech commented Jul 27, 2018

I probably need more use cases to know what's the issues is. Do you mean the Unicode encoding is incorrect?

@nikukyugamer
Copy link
Author

nikukyugamer commented Jul 27, 2018

thank you for reply.

first of all, I found important mistake in my below description.

note: although executing on console directly no error occurs, on the other hand by cron executing error occurs

precisely, the error doesn't occur at gem version 0.0.19. but at 1.0.0 the error occurs. so it doesn't matter the execution environment such as on console or on cron.

however at 0.0.19, the warning message is shown as below.

Could not coerce フィールド名: フィールドの値

btw I forgot to submit one important log. Using patched gem by me, the execution doesn't stop and this warning message is shown.

Could not coerce フィールド名: フィールドの値 due to invalid value for BigDecimal(): "フィールドの値"

I guess the multibyte chars with inserting incorrect field type value cause this problem...

@mech
Copy link
Owner

mech commented Jul 27, 2018

If I am not wrong, Ruby version 2 should be Unicode by default. So there is no need to really force any encoding even if you are using Japanese.

You are saying using console is working right and only cron gives problem?

@nikukyugamer
Copy link
Author

nikukyugamer commented Jul 27, 2018

You are saying using console is working right and only cron gives problem?

sorry, it is my mistake.

when using console, the gem version was 0.0.19 and executed successfully.
when using cron, the gem version was 1.0.0 and failed to execute.
and when using console with gem version 1.0.0, also failed.

Ruby version is 2.5.1.

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

Successfully merging this pull request may close these issues.

None yet

2 participants