m-ld / timeld

Live shared timesheets
MIT License
1 stars 1 forks source link

Help understanding a conflict #87

Closed michielbdejong closed 2 years ago

michielbdejong commented 2 years ago

Please help me understand this conflict. There are no timesheets in my name and also none in the name of the fedb project:

$ timeld admin
reading config file from /Users/michiel/Library/Preferences/timeld-nodejs/config.json
reading config file from /Users/michiel/Library/Preferences/timeld-nodejs/config.json
michielbdejong> list timesheet
michielbdejong> list link --project=fedb/fedt
angus/ts-agm-2022-08-08
angus/ts-agm-2022-08-15
angus/ts-agm-2022-08-22
angus/ts-agm-2022-08-29
angus/ts-agm-2022-09-05
angus/ts-agm-2022-09-12
george/fedt
george/fedt-1
victor/federated-timesheets

Now I create this small timesheet file:

$ cat test.ndjson 
{"@id":"fedb/fedt","@type":"Project"}
{"@id":"fedb/fedt-http-time-pondersource-com-ismoil","project":[{"@id":"fedb/fedt"}],"@type":"Timesheet"}
{"activity":"Worked","session":{"@id":"fedb/fedt-http-time-pondersource-com-ismoil"},"duration":480,"start":{"@value":"2022-03-25T00:00:00+00:00","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},"@type":"Entry","vf:provider":{"@id":"http://time.pondersource.com/ismoil"},"external":{"@id":"http://time.pondersource.com/movement/1"}}

And trying to upload it reports 'Conflict':

$ curl -i --data-binary "@test.ndjson" -H "Accept: Content-Type: application/x-ndjson" https://$CREDENTIALS@timeld.org/api/import
HTTP/1.1 409 Conflict
server: Fly/51ee4ef9 (2022-09-20)
content-type: application/json
content-length: 32
date: Wed, 21 Sep 2022 08:16:07 GMT
connection: keep-alive
keep-alive: timeout=5
via: 1.1 fly.io
fly-request-id: 01GDFHWNN8QVP48ZHHN6P98MW4-ams

{"code":"Conflict","message":""}

What am I doing wrong? Is there data already in other timesheets that conflicts with my timesheet data somehow?

gsvarovsky commented 2 years ago

Has "fedb/fedt-http-time-pondersource-com-ismoil" ever existed before (and maybe been deleted)?

Once a timesheet ID has been created on a gateway its ID can never be re-used. That was implemented because timesheets are replicated to devices, and the gateway can't know whether a device is offline. Big problems could arise if the ID is reincarnated before the device comes back online, causing it to try to "merge" its operations with a domain that knows nothing about it.

However, this "feature" could be improved on with some extra thought – we could assign an incrementing "recycled" count for IDs and use those as m-ld domain identities.

michielbdejong commented 2 years ago

Ah that must be it! OK, I'll just add some additional characters to the timesheet name on my end