Skip to content

Fix Oban configuration and status checks - #192

Merged
ddon merged 4 commits into
BeamLabEU:devfrom
timujinne:dev
Nov 22, 2025
Merged

Fix Oban configuration and status checks#192
ddon merged 4 commits into
BeamLabEU:devfrom
timujinne:dev

Conversation

@timujinne

Copy link
Copy Markdown
Contributor

Summary

  • Fix Oban configuration detection and automatic restart
  • Improve status check messages to include Oban configuration
  • Fix database connection check in phoenix_kit.status

Changes

Bug Fixes

  • Fix Oban config detection and add automatic restart capability
  • Update show_missing_config_message to properly include Oban configuration
  • Fix phoenix_kit.status database connection check

Test Plan

  • Pre-commit checks passed (mix format, mix quality)
  • Manual testing completed
  • Oban configuration detection working correctly
  • Database connection checks functioning properly

Fixed issue where mix phoenix_kit.status was showing "Connection failed"
even when the database was properly configured and accessible.

Problem:
- The task attempted to minimize app startup to avoid conflicts
- Complex conditional logic in ensure_app_started/0 failed to properly
  initialize the Ecto repository
- Repository process was not available during status checks

Solution:
- Simplified run/1 to use standard Mix.Task.run("app.start")
- Removed unnecessary ensure_app_started/0 function
- Now properly starts the application with all dependencies including repo

Result:
- Database connection check now works correctly in all installations
- Status command shows accurate "Connected ✅" when database is available
- Will work consistently across all PhoenixKit installations
The message shown to users when configuration is missing did not
mention Oban (background jobs for file processing), although the
code already checks for Oban configuration and adds it when missing.

This created confusion as:
- The code checks 3 configurations (Ueberauth, Hammer, Oban)
- The message only mentioned 2 (Ueberauth, Hammer)
- install.ex already had the correct message with Oban
- update.ex was missing this line

Now both install.ex and update.ex show consistent messages
to users about all required configurations.
This commit fixes the infinite loop issue where mix phoenix_kit.update
would get stuck checking for Oban configuration and never execute
migrations.

Problems fixed:
1. has_active_oban_config? was checking for hardcoded app name
   - BEFORE: Searched for "config :phoenix_kit, Oban"
   - AFTER: Searches for ", Oban" to match any app name
   - This fix applied to both install.ex and update.ex

2. No automatic restart after adding configuration
   - Commands now automatically restart instead of asking user
   - Uses is_retry flag and recursive run(argv) call
   - Prevents infinite loops with {:missing, true} safety check

3. Removed unused code that caused compilation warnings
   - Removed unused 'result' variable in both files
   - Removed show_config_added_message/1 function (no longer needed)

Technical implementation:
- Pattern match on {config_status, is_retry} tuple
- First pass {:missing, false}: Add config + automatic restart
- Second pass {:ok, _}: Execute migrations normally
- Safety check {:missing, true}: Prevent infinite loops

Results:
- mix phoenix_kit.update now completes in one command
- Automatically detects missing Oban config (any app name)
- Automatically adds config and reruns
- Executes migrations without manual intervention
- No more "run again" messages - fully automatic

Also includes:
- Comment explaining igniter usage in mix.exs
@ddon
ddon merged commit caf4b06 into BeamLabEU:dev Nov 22, 2025
6 checks passed
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.

2 participants