Skip to content

[Bug]: fix: translated_text in Kanta.Translations.PluralTranslation can be nil #137 #138

@kubosuke

Description

@kubosuke

Kanta version

0.5

Elixir/OTP/Phoenix version

❯ elixir -v Erlang/OTP 28 [erts-16.1] [source] [64-bit] [smp:11:11] [ds:11:11:10] [async-threads:1] [jit] Elixir 1.19.2 (compiled with Erlang/OTP 26)

Database

PostgreSQL

Bug description

** (exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in Gettext.Interpolation.Default.runtime_interpolate/2
        (gettext 1.0.2) lib/gettext/interpolation/default.ex:101: Gettext.Interpolation.Default.runtime_interpolate(nil, %{count: 2})
        (kanta 0.5.1) lib/kanta/backend/adapter/cached_db.ex:131: Kanta.Backend.Adapter.CachedDB.apply_bindings/2
        (kanta 0.5.1) lib/kanta/backend/adapter/cached_db.ex:108: Kanta.Backend.Adapter.CachedDB.lngettext/7
        (myapp 0.1.0) lib/myapp_web/gettext.ex:23: myappWeb.Gettext."handle_missing_plural_translation (overridable 2)"/7
        (myapp 0.1.0) lib/myapp_web/gettext.ex:153: myappWeb.Gettext.handle_missing_plural_translation/7
        (gettext 1.0.2) lib/gettext.ex:987: Gettext.dpngettext/7
        (myapp 0.1.0) lib/myapp_web/live/listing_live/components/listing.ex:14: anonymous fn/2 in myappWeb.Listing.Components.Listing.render/1
        (phoenix_live_view 1.1.17) lib/phoenix_live_view/diff.ex:420: Phoenix.LiveView.Diff.traverse/6
        (phoenix_live_view 1.1.17) lib/phoenix_live_view/diff.ex:609: anonymous fn/3 in Phoenix.LiveView.Diff.traverse_dynamic/6
        (elixir 1.18.3) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
        (phoenix_live_view 1.1.17) lib/phoenix_live_view/diff.ex:419: Phoenix.LiveView.Diff.traverse/6
        (phoenix_live_view 1.1.17) lib/phoenix_live_view/diff.ex:609: anonymous fn/3 in Phoenix.LiveView.Diff.traverse_dynamic/6
        (elixir 1.18.3) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
        (phoenix_live_view 1.1.17) lib/phoenix_live_view/diff.ex:419: Phoenix.LiveView.Diff.traverse/6
        (phoenix_live_view 1.1.17) lib/phoenix_live_view/diff.ex:146: Phoenix.LiveView.Diff.render/4
        (phoenix_live_view 1.1.17) lib/phoenix_live_view/static.ex:291: Phoenix.LiveView.Static.to_rendered_content_tag/4
        (phoenix_live_view 1.1.17) lib/phoenix_live_view/static.ex:171: Phoenix.LiveView.Static.do_render/4
Image

Steps to reproduce

run Gettext.ngettext to the msgid whose translated_text is not registered to the kanta table

Code sample

Expected behavior

this should be trapped in

_ -> {:error, :not_found}

Actual behavior

raise exception as above

Error logs/stack trace

Additional context

No response

Checklist

  • I have searched for existing issues before creating this one
  • I have provided all the requested information
  • This is a bug report, not a feature request or question. For general questions, please use Kanta Slack channel or GitHub Discussions.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions