Our Personal Data Server from scratch! tranquil.farm
pds rust database fun oauth atproto

declaredAgePref isn't generated from valid birthDates #718

Open secluded.site
Open opened by secluded.site

Hello o/

I found this while testing migrating my account from the reference PDS to tranquil v0.6.6-31-g3ade3d1

Tranquil currently parses personalDetailsPref.birthDate as %Y-%m-%d. Its tests also use date-only values. Afaict, this is incorrect.

birthDate uses the datetime format and the ATProto datetime spec requires a full timestamp with timezone information. The @atproto/api client serializes JS dates with toISOString(), producing values like 2000-01-01T00:00:00.000Z. The reference PDS reads that timestamp and generates declaredAgePref.

So declaredAgePref is lost after migrating:

  1. Original PDS has personalDetailsPref.birthDate and generated declaredAgePref
  2. Tranquil's putPreferences stores personalDetailsPref
  3. It discards the submitted declaredAgePref because it's read-only
  4. getPreferences can't parse the timestamp from personalDetailsPref.birthDate
  5. So it doesn't generate its own declaredAgePref

You should be able to reproduce by setting this from a full-access session

{
  "$type": "app.bsky.actor.defs#personalDetailsPref",
  "birthDate": "2000-01-01T00:00:00.000Z"
}

Then calling getPreferences to see whether it returns birthDate and a generated declaredAgePref, or only birthDate.

I'm very new to the Atmosphere and happy to be told I've utterly misunderstood things! If it sounds right, I've got a fix I can open a PR for whenever 😃

I've got a fix I can open a PR for whenever

I finished migrating to a version of tranquil with this patch applied and it's working as expected so far!

Sign up or Sign in to add to the discussion.