Skip to content

Implicit App Discovery is Brittle (Use CUSTOM_APPS Instead) #979

@wesleyboar

Description

@wesleyboar

Note

Generated by AI. Edited by @wesleyboar.

Summary

taccsite_cms/settings.py currently scans taccsite_custom subdirectories with a helper like get_subdirs_as_module_names and appends them to INSTALLED_APPS at runtime. This implicit app discovery is brittle and causes surprising behavior.

Files / Locations

  • taccsite_cms/settings.py — discovery + append to INSTALLED_APPS

Problems / Impact

  • Non-deterministic app ordering can break template resolution, signal/middleware ordering, and migrations.
  • Makes it hard to reason about which apps are enabled; accidental subdirs can be loaded as apps.
  • Hard to test and CI-validate because the environment can produce different lists depending on filesystem order/globs.
  • Migration and management commands can behave differently between environments.

Proposed (Backward-Compatible) Approach

  1. Use existing optional setting CUSTOM_APPS (list of module names). Use it instead of scanning.
  2. If keeping current scanning behavior as a fallback for backward compatibility:
    • Sort discovered module names deterministically (e.g. alphabetically) before appending.
    • Emit a deprecation warning (e.g. logging.warn) when discovery is used.
  3. Add a validation step on startup (or a management command) that prints the final INSTALLED_APPS order and flags duplicates or likely issues.
  4. Document the new setting in taccsite_custom/README.md and docs/ with migration steps.

Minimal Migration Plan / Tests

  • Tests: unit test that discovery returns a stable, sorted list; integration test that explicitly provided TACCSITE_CUSTOM_APPS results in expected INSTALLED_APPS.

Warning

Teams who want determinism can use setting CUSTOM_APPS, but use of that setting can not be an "opt-in" signal, because all custom Core-CMS instances already use CUSTOM_APPS (for other custom apps).

Client Apps

These apps rely on TACC/Core-CMS:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovements or additions to existing features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions