Skip to content

feat: validate AUTHSOME_HOME against running daemon via health check to prevent directory mismatch errors#304

Open
ankitranjan7 wants to merge 1 commit into
mainfrom
feature/daemon-home-mismatch
Open

feat: validate AUTHSOME_HOME against running daemon via health check to prevent directory mismatch errors#304
ankitranjan7 wants to merge 1 commit into
mainfrom
feature/daemon-home-mismatch

Conversation

@ankitranjan7
Copy link
Copy Markdown
Collaborator

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 current AUTHSOME_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 /health response 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 like mktemp -d.

Before this change:

  • authsome whoami could talk to an already-running daemon that was started from a different home directory
  • authsome daemon stop only looked for the PID file under the current AUTHSOME_HOME
  • the result was inconsistent behavior where commands appeared to disagree about which Authsome home was active

With 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.py
  • uv run ty check src/
  • uv run pytest
  • uv tool run pre-commit run --all-files

Added coverage for:

  • allowing reuse when the running daemon home matches the current AUTHSOME_HOME
  • rejecting reuse when the running daemon home differs from the current AUTHSOME_HOME

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • All new and existing tests 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.

1 participant