terminusdb icon indicating copy to clipboard operation
terminusdb copied to clipboard

id of document with no key strategy was allowed to be set to something containing a '/'

Open matko opened this issue 4 years ago • 2 comments

This came up during the stargazer example project. Through the python client, a Repository object (which has no key strategy) was inserted with id 'terminusdb:///data/Repository/terminusdb/terminusdb'. It seems odd to me that a '/' was allowed in the id, as this usually denotes an object hierarchy. Shouldn't we have enforced this to be escaped?

matko avatar Oct 27 '21 15:10 matko

To reproduce:

#!/bin/bash
set -ex

HOST='http://admin:root@localhost:6363'

# Create database
xh DELETE "$HOST/api/db/admin/tdb" label=l comment=c
xh "$HOST/api/db/admin/tdb" label=l comment=c

# Create schema
xh "$HOST/api/document/admin/tdb" graph_type==schema author==a message==m <<EOF
{"@id":"X","@type":"Class"}
EOF

# Insert instance
xh "$HOST/api/document/admin/tdb" author==a message==m <<EOF
{"@type":"X","@id":"X/with/more/slash"}
EOF

# Get instance
xh "$HOST/api/document/admin/tdb"

Output from last two commands:

[
    "terminusdb:///data/X/with/more/slash"
]
{
    "@id": "X/with/more/slash",
    "@type": "X"
}

spl avatar Oct 28 '21 14:10 spl

We could use https://github.com/terminusdb/terminusdb/issues/747 for migrating existing documents.

spl avatar Nov 08 '21 14:11 spl