fluree / db

Fluree database library
https://fluree.github.io/db/
Other
340 stars 22 forks source link

DX for ledger creation #398

Open flyingmachine opened 1 year ago

flyingmachine commented 1 year ago

If you create a ledger with an empty txn:

{
    "ledger": "example-ledger",
    "txn": {}
}

And then transact data:

{
    "ledger": "example-ledger",
    "txn": {"name": "Derek"}
}

The response includes an error with the message "Commit has neither assertions or retractions!".

I found this to be confusing and have some concerns:

mpoffald commented 1 year ago

@flyingmachine Sorry, I just now saw this when browsing issues. We implemented a change recently to disallow persisting empty transactions (or transactions that have just an @id, which is insufficient) in the first place (issue: https://github.com/fluree/db/issues/402, PR: https://github.com/fluree/db/pull/407).

mpoffald commented 1 year ago

I realize this does not address all of this feedback, but I wanted to make you aware of the change in case you weren't already. A user attempting to create a ledger with an empty transaction will now get an error like "Invalid transaction, transaction node contains no properties for: @id: http://example.org/ns/someone".

So they will at least receive that error when they attempt it in the first place, instead of getting a misleading success response and then getting a confusing error the next time they interact with the ledger.