feat: validate AUTHSOME_HOME against running daemon via health check to prevent directory mismatch errors#304
feat: validate AUTHSOME_HOME against running daemon via health check to prevent directory mismatch errors#304ankitranjan7 wants to merge 1 commit into
Conversation
…to prevent directory mismatch errors
manojbajaj95
left a comment
There was a problem hiding this comment.
Need the movtivation behind these changes.
|
@manojbajaj95 If a daemon is running already (which is always true if authsome is being used), and then AUTHSOME_HOME is then set differently, "authsome whomai" prints the original Home directory since the daemon is still pointing to the original authsome_home directory and authsome daemon stop also does not work since it checks for the PID file in the new home directory path. This PR just checks the where the currently running dameon is pointing to and make sure the AUTHSOME_HOME matches that . OR else it shows an appropriate error message something like :- "Error: Authsome daemon at http://127.0.0.1:7998 is already running with home '/Users/ankitranjan/.authsome', but current AUTHSOME_HOME is '/var/folders/mv/cmf60kpj1g1cqsxsj_2bwjv40000gn/T/tmp.KtiWNOFTXA'. Stop the existing daemon or unset/change AUTHSOME_HOME before retrying." |
Description
Adds a daemon-home mismatch guard for the local managed daemon.
When Authsome is pointed at the default local daemon URL (
127.0.0.1:7998), it now checks the running daemon’s home directory before reusing it. If the daemon is already running with a different home than the currentAUTHSOME_HOME, Authsome fails fast with a clear error instead of silently talking to the wrong daemon.This also adds the daemon home path to the unprotected
/healthresponse so the CLI can make that check safely.Motivation and Context
This fixes a confusing local workflow bug when switching
AUTHSOME_HOME, especially with ephemeral directories likemktemp -d.Before this change:
authsome whoamicould talk to an already-running daemon that was started from a different home directoryauthsome daemon stoponly looked for the PID file under the currentAUTHSOME_HOMEWith this change, Authsome surfaces the mismatch explicitly and tells the user to stop the existing daemon or change/unset
AUTHSOME_HOME.How Has This Been Tested?
Tested with:
uv run ruff check src/authsome/cli/daemon_control.py src/authsome/server/routes/health.py src/authsome/server/schemas.py tests/cli/test_daemon_control.pyuv run ty check src/uv run pytestuv tool run pre-commit run --all-filesAdded coverage for:
AUTHSOME_HOMEAUTHSOME_HOMETypes of changes
Checklist: