terminusdb / terminusdb

TerminusDB is a distributed database with a collaboration model
https://terminusdb.com
Apache License 2.0
2.78k stars 108 forks source link

Internal server error when changing schema with API #34

Closed rrooij closed 4 years ago

rrooij commented 5 years ago

Error

The following error appears when trying to change the schema from the terminus-server API:

{
  "code":500,
  "message":"Type error: `json_term' expected, found `base64_char(_9532,58)' (a compound)"
}

Expected result

A clear error message or a changed schema.

How to reproduce

  1. Create a database called testdb.
  2. Run the folllowing python3 script:
#!/usr/bin/env python3
import requests

headers = { 'Authorization' : 'Basic %s' %  ":root" }

small_turtle = """
@base <http://example.org/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rel: <http://www.perceive.net/schemas/relationship/> .

<#green-goblin>
    rel:enemyOf <#spiderman> ;
    a foaf:Person ;    # in the context of the Marvel universe
    foaf:name "Green Goblin" .

<#spiderman>
    rel:enemyOf <#green-goblin> ;
    a foaf:Person ;
    foaf:name "Spiderman" .
"""
payload = {
    "terminus:turtle": small_turtle,
    "terminus:schema": "http://localhost:6363/testdb/schema",
    "@type": "terminus:APIUpdate"
}
response = requests.post("http://localhost:6363/testdb/schema", json=payload, headers=headers)
print(response.text)
rrooij commented 5 years ago

Can be related to missing nested json encoding or the like? As uploading this with curl works fine.

curl 'http://localhost:6363/testdb/schema' -X POST -H "Content-Type: application/json" --user ':root' -d@payload.json

payload.json:


{"terminus:turtle": "\n@base <http://example.org/> .\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n@prefix rel: <http://www.perceive.net/schemas/relationship/> .\n\n<#green-goblin>\n    rel:enemyof <#spiderman> ;\n    a foaf:person ;    # in the context of the marvel universe\n    foaf:name \"green goblin\" .\n\n<#spiderman>\n    rel:enemyof <#green-goblin> ;\n    a foaf:person ;\n    foaf:name \"spiderman\" .\n", "terminus:schema": "http://localhost:6363/testdb/schema", "@type": "terminus:apiupdate"}
GavinMendelGleason commented 4 years ago

Anyone know the status of this issue?

kevinchekovfeeney commented 4 years ago

This no longer applies - problem is in original script :root should be base64 encoded