Skip to content

fix: persist Moltbook auth DIDs and deduplicate by moltbook_id#4

Open
HaraldeRoessler wants to merge 1 commit intoMoltyCel:mainfrom
HaraldeRoessler:fix/moltbook-auth-orphan-dids
Open

fix: persist Moltbook auth DIDs and deduplicate by moltbook_id#4
HaraldeRoessler wants to merge 1 commit intoMoltyCel:mainfrom
HaraldeRoessler:fix/moltbook-auth-orphan-dids

Conversation

@HaraldeRoessler
Copy link
Copy Markdown
Contributor

Summary

  • /auth/moltbook now stores the agent in the database on first authentication
  • Repeated auth calls for the same Moltbook user return the same DID (lookup by moltbook_id + platform='moltbook')
  • Only creates a new agent record on first auth

Problem

The endpoint generated a new random DID on every call (uuid.uuid4()) without inserting it into the agents table. This meant:

  • Repeated logins returned different DIDs each time
  • The returned DID was useless (not registered, could not be used with any other endpoint)
  • Orphan DIDs accumulated conceptually with no cleanup

Test plan

  • First /auth/moltbook call with valid token creates agent and returns DID
  • Second call with same user token returns the same DID
  • DID appears in /identity/resolve/{did}
  • Different Moltbook users get different DIDs

Generated with Claude Code

The /auth/moltbook endpoint generated a new random DID on every call
without storing it, creating orphan DIDs that could never be used with
other endpoints. Repeated auth calls for the same user returned
different DIDs each time.

Now looks up existing agent by moltbook_id (stored as display_name with
platform='moltbook'). Returns the same DID on repeated auth. Only
creates a new agent on first authentication.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@HaraldeRoessler
Copy link
Copy Markdown
Contributor Author

Merge order

Independent — can merge in any order relative to #2 and #7.

Sequence: #1#3#2#4#7

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