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

Rails cache storage not working propertly #48748

Closed
benone opened this issue Jul 17, 2023 · 1 comment · Fixed by #48751
Closed

Rails cache storage not working propertly #48748

benone opened this issue Jul 17, 2023 · 1 comment · Fixed by #48751
Assignees

Comments

@benone
Copy link

benone commented Jul 17, 2023

Steps to reproduce

  1. Init new app
rails new rails-test --main
cd rails-test
bundle add dalli
touch tmp/caching-dev.txt
  1. Set cache store in development.rb
config.cache_store = :mem_cache_store
  1. Run console
rails c
  1. Try to write cache
irb(main):001:0> Rails.cache.clear
Dalli::Server#connect 127.0.0.1:11211
=> [true]
irb(main):002:0> Rails.cache.write("test", "Más")
/Users/benone/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/bundler/gems/rails-e18791c0bf2e/activesupport/lib/active_support/cache/serializer_with_fallback.rb:80:in `try_dump_bare_string': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)

Expected behavior

Written cache.

Actual behavior

Encoding::CompatibilityError Exception

System configuration

Rails version:
rails main (e18791c)

Ruby version:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [arm64-darwin22]

Related issue:

#48196

@jonathanhefner jonathanhefner self-assigned this Jul 17, 2023
jonathanhefner added a commit to jonathanhefner/rails that referenced this issue Jul 17, 2023
To use a binary-encoded string as a byte buffer, appended strings should
be force-encoded as binary.  Otherwise, appending a non-ASCII-only
string will raise `Encoding::CompatibilityError`.

Fixes rails#48748.
@jonathanhefner
Copy link
Member

Thank you for the bug report! 🙏 I should have written a more end-to-end test in #48197. This should now be fixed by #48751.

paulreece pushed a commit to paulreece/rails-paulreece that referenced this issue Aug 26, 2023
To use a binary-encoded string as a byte buffer, appended strings should
be force-encoded as binary.  Otherwise, appending a non-ASCII-only
string will raise `Encoding::CompatibilityError`.

Fixes rails#48748.
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 a pull request may close this issue.

2 participants