Skip to content

feat: resolve GitHub webhook user_id — replace default_user with repo-mapped identity#41

Merged
Adilislam0 merged 4 commits into
Life-Atlas:stagingfrom
iamaryan07:staging_new
Jun 25, 2026
Merged

feat: resolve GitHub webhook user_id — replace default_user with repo-mapped identity#41
Adilislam0 merged 4 commits into
Life-Atlas:stagingfrom
iamaryan07:staging_new

Conversation

@iamaryan07

Copy link
Copy Markdown
Collaborator

Summary

Problem

GitHub webhook events (PR merged, PR reviewed, commit pushed) were being
received by webhooks.py but never saved to the database. The commented-out
save code had "user_id": "default_user" hardcoded — there was no mechanism
to know which platform user the incoming webhook belonged to.

Solution

Added a reverse mapping (repo_db) in github_auth.py that stores
"owner/repo" → user_id whenever a user registers a webhook via /track-repo.
webhooks.py now reads repository.full_name from the incoming payload,
looks up the real user_id from that mapping, and saves the signal.

Changes

  • github_auth.py — added repo_db: dict[str, str]; populated on
    /track-repo success (including 422 "already exists"); cleared on
    /disconnect-repo
  • webhooks.py — un-commented and rewired the signal save block; imports
    repo_db, store, Signal; skips silently (with warning log) if the
    repo is not registered; saves a proper Signal object with the real
    user_id

Behaviour

  • Signals from GitHub events are now saved with the correct user's UUID
  • If a webhook fires for an unregistered repo, the event is dropped with
    a console warning (no crash, no phantom data)
  • No changes to any other files — no merge conflicts expected

Known limitation

repo_db (and token_db) are in-memory. A server restart clears all
registered repos — users would need to re-register via /track-repo.
This is a pre-existing limitation of the architecture, not introduced here.

@Adilislam0 Adilislam0 merged commit e50a847 into Life-Atlas:staging Jun 25, 2026
1 check passed
thedgarg31 added a commit to thedgarg31/lpi-platform that referenced this pull request Jun 26, 2026
…fe-Atlas#41)

- Updated signal ingestion diagram to show 3 signal paths:
  GitHub webhook (auto, repo_db resolves user_id), manual POST, external sources
- Updated end-to-end trace: step 2 now shows track-repo populating repo_db,
  step 4 shows webhook resolving user_id from repo_db instead of default_user
- Updated GitHub Auth API table with repo_db explanation note
- Webhook now fully wired: GitHub event -> activity_signals -> recommendations
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