409 When deleting an existing subject
Hello I'm unable to delete an existing subject from a document. I've reduced the problematic code to this:
//login
const session = await auth.currentSession();
if (!session) {
await auth.login("https://solidcommunity.net");
}
// get pod doc url
const a = document.createElement('a');
a.href = webId;
const documentUrl = `${a.protocol}//${a.hostname}/private/tmp/tripledoc-bug.ttl`;
// get document
let podDocument = null
try {
podDocument = await fetchDocument(documentUrl);
} catch (err) {
podDocument = await createDocument(documentUrl);
}
// create subject and save
const amountSubject = podDocument.addSubject()
amountSubject.addRef(RDF.type, schema.MonetaryAmount)
amountSubject.setString(schema.currency, "USD")
amountSubject.setDecimal(schema.amount, 1.0)
await podDocument.save()
// fetch document against, delete the subject, and save
podDocument = await fetchDocument(documentUrl);
podDocument.getAllSubjectsOfType(schema.MonetaryAmount).forEach((s) => {
podDocument.removeSubject(s.asRef())
})
await podDocument.save()
Expected result: Successfully delete the subject on the last line podDocument.save()
Actual Result: Patch 409:
fetchWithCredentials @ main.js:59183
async function (async)
fetchWithCredentials @ main.js:59181
authnFetch @ main.js:58523
async function (async)
authnFetch @ main.js:58515
fetch @ main.js:57886
(anonymous) @ main.js:70923
step @ main.js:70782
(anonymous) @ main.js:70763
fulfilled @ main.js:70753
Promise.then (async)
step @ main.js:70755
fulfilled @ main.js:70753
Promise.then (async)
step @ main.js:70755
(anonymous) @ main.js:70756
__awaiter @ main.js:70752
update @ main.js:70907
(anonymous) @ main.js:71569
step @ main.js:70782
(anonymous) @ main.js:70763
(anonymous) @ main.js:70756
__awaiter @ main.js:70752
save @ main.js:71563
(anonymous) @ main.js:74395
async function (async)
(anonymous) @ main.js:74364
main.js:71576 Uncaught (in promise) Error: The patch could not be applied. Could not find to delete: <https://sbrackentest.solidcommunity.net/private/tmp/tripledoc-bug.ttl#16057417332626485688452702014> <http://schema.org/amount> "1.0"^^<http://www.w3.org/2001/XMLSchema#decimal> .
or <https://sbrackentest.solidcommunity.net/private/tmp/tripledoc-bug.ttl#1605741791396550413401268893> <http://schema.org/amount> "1.0"^^<http://www.w3.org/2001/XMLSchema#decimal> .
at main.js:71576
at step (main.js:70782)
at Object.next (main.js:70763)
at fulfilled (main.js:70753)
Here's a working example of the bug: https://github.com/abigpotostew/solid-bugs
Using libraries: @inrupt/solid-client: ^1.1.0 @inrupt/vocab-common-rdf: ^0.6.3 rdf-namespaces: ^1.9.2 solid-auth-client: ^2.5.3 tripledoc: ^4.4.0