Narrow compile_env to leaf keys in :persistence and :cache#209
Open
rranelli wants to merge 1 commit into
Open
Conversation
`Application.compile_env/3` was previously called on the entire `:persistence` and `:cache` keyword lists, which caused every key inside those lists to be tracked at compile time — including keys that the library only ever reads at runtime (`:repo`, `:adapter`, `:ttl`). Any host application that legitimately overrode those keys in `runtime.exs` would trip Elixir's release-boot `validate_compile_env` check and abort. Only three leaves are actually consumed at compile time: * `:persistence.ecto_table_name` — interpolated into `schema(...)` in `FunWithFlags.Store.Persistent.Ecto.Record`. * `:persistence.ecto_primary_key_type` — used in the `@primary_key` attribute in the same module. * `:cache.enabled` — used by `store_module_determined_at_compile_time/0` to pick between `FunWithFlags.Store` and `FunWithFlags.SimpleStore`. This change uses path-style `Application.compile_env/3` to track only those leaves. All other keys in `:persistence` and `:cache` are once again free to be overridden at runtime without causing a boot failure, restoring the v1.6.0 intent of not compiling in the Ecto repo while keeping the v1.9.0 safety check for the keys that actually need it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Application.compile_env/3was previously called on the entire:persistenceand:cachekeyword lists, which caused every key inside those lists to be tracked at compile time — including keys that the library only ever reads at runtime (:repo,:adapter,:ttl). Any host application that legitimately overrode those keys inruntime.exswould trip Elixir's release-bootvalidate_compile_envcheck and abort.Only three leaves are actually consumed at compile time:
:persistence.ecto_table_name— interpolated intoschema(...)inFunWithFlags.Store.Persistent.Ecto.Record.:persistence.ecto_primary_key_type— used in the@primary_keyattribute in the same module.:cache.enabled— used bystore_module_determined_at_compile_time/0to pick betweenFunWithFlags.StoreandFunWithFlags.SimpleStore.This change uses path-style
Application.compile_env/3to track only those leaves. All other keys in:persistenceand:cacheare once again free to be overridden at runtime without causing a boot failure, restoring the v1.6.0 intent of not compiling in the Ecto repo while keeping the v1.9.0 safety check for the keys that actually need it.