Skip to content

fix: require compile-time global resource config#147

Open
tfwright wants to merge 1 commit into
mainfrom
fix/compile-time-resource-config
Open

fix: require compile-time global resource config#147
tfwright wants to merge 1 commit into
mainfrom
fix/compile-time-resource-config

Conversation

@tfwright
Copy link
Copy Markdown
Owner

Summary

  • Global resource config (every key in base_configs_schema/0 except ecto_repo) is captured via Application.compile_env in the live_admin macro and passed to build_session/4. Application.get_env is no longer used as a fallback for these keys.
  • LiveAdmin.Application.start/2 calls a new validate_compile_time_config!/0 that compares each key's compile-time value to the current runtime value and raises on mismatch, pointing the user to config/config.exs.
  • README and base_configs_schema/0 docstring now spell out which app-level keys are compile-time and which (ecto_repo, session_store, gettext_backend, css_overrides) stay runtime.

Test plan

  • mix test (44 tests, 0 failures) — includes new build_session/4 describes covering app_config lookup, runtime env being ignored, and list defaults, plus LiveAdmin.ApplicationTest covering the boot-time mismatch raise.
  • mix compile --warnings-as-errors
  • mix credo — no new violations
  • Smoke test the demo (mix dev) after merge to confirm :immutable_fields configured via Application.put_env before the demo router compiles still flows through

Global resource config (everything in `base_configs_schema/0`
except `ecto_repo`) is now read at compile time at the application
level, so misconfigurations surface at build time and the value
used by the running app cannot diverge from what was validated.
Previously only `create_with` and `update_with` were compile-time
for the conflict check; everything else fell back to
`Application.get_env` at runtime. A boot check raises if any of
these keys differs between compile and runtime env, pointing the
user to `config/config.exs`.
@tfwright tfwright force-pushed the fix/compile-time-resource-config branch from 018e867 to d9817a6 Compare May 15, 2026 20:10
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.

1 participant