RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.18k stars 558 forks source link

Specifiying charset in content type in SPARQLconnector.update() breaks connect to Fuseki backend #2420

Open chrysle opened 1 year ago

chrysle commented 1 year ago

I was using the SPARQLUpdateStore class to perform an update request to an Apache Jena Fuseki backend, but received the following traceback:

urllib.error.HTTPError: HTTP Error 400: Unknown content type for triples: [application/sparql-update charset=UTF-8]

The charset in the content type is specified here:

https://github.com/RDFLib/rdflib/blob/3188e7f5b88fea99e5e3dd28f08de25c0f56fcdc/rdflib/plugins/stores/sparqlconnector.py#L170

Removing the charset from the content type worked fine. Is that a candidate for default behaviour?

chrysle commented 1 year ago

@aucampia Sorry for pinging, but since this is blocking an update from Sleepycat to BerkeleyDB (and support for Python 3.10+), could you maybe leave a comment?

aucampia commented 1 year ago

@chrysle as far as I understand what we send as content type is valid syntax, and not sending encoding causes problems for other endpoints.

This encoding was added in https://github.com/RDFLib/rdflib/pull/2112 to fix https://github.com/RDFLib/rdflib/issues/2095. We could potentially look at making it optional, but if it is a valid value for Content-Type then ideally Fuseki should accept it.

chrysle commented 1 year ago

Thank you for responding!

This encoding was added in #2112 to fix #2095. We could potentially look at making it optional, but if it is a valid value for Content-Type then ideally Fuseki should accept it.

Hm, then I'm unsure why I'm experiencing it. I'm using this Fuseki docker image in version 3.6.0. You can see a reproduction of the issue at chrysle/gutenberg#2.

aucampia commented 1 year ago

I'm using this Fuseki docker image in version 3.6.0.

Could you try with a newer version? I think the latest is 4.8.0, though I may be wrong.

chrysle commented 1 year ago

Could you try with a newer version? I think the latest is 4.8.0, though I may be wrong.

I've tried with latest, which is in this particular image 3.14.0. Official documentation claims the newest version is 4.8.0, but I can't find a docker image with that version.

This, however, seems to break Graph().add(). I used that method with triples such as this:

(rdflib.term.URIRef('http://www.gutenberg.org/ebooks/5.epub.images'), rdflib.term.URIRef('http://purl.org/dc/terms/modified'), rdflib.term.Literal('2015-12-01T01:00:44.902096', datatype=rdflib.term.URIRef('http://www.w3.org/2001/XMLSchema#dateTime')))

This is what I got:

urllib.error.HTTPError: HTTP Error 400: Neither ?default nor ?graph in the query string of the request
namedgraph commented 1 year ago

@chrysle not being able to parse the charset param sounds like a Jena issue. Can you open an issue there? https://github.com/apache/jena/issues