LDPSerializer: Key error with mismatched urlid
As of DjangoLDPv2.1 there will be a test in tests_model_serializer.py
:
job = JobOffer.objects.create(title="job test")
# contains internal urlid which refers to a container
post = {"@id": "{}/job-offers/{}/".format(settings.BASE_URL, job.slug),
"skills": {
"ldp:contains": [
{"@id": "{}/skills/".format(settings.BASE_URL)},
]}
}
serializer_class = self._get_serializer_class(JobOffer, 2, ("@id", "title", "skills"))
serializer = serializer_class(data=post, instance=job)
serializer.is_valid(raise_exception=True)
result = serializer.save()
Note that the skills
resource here is intentionally a container rather than a valid url
Running this, the code makes it to build_nested_field
, where it decides that it's a local resource (from the URL) and attempts to resolve the url. It raises a KeyError
, relating to the fact that it is unable to resolve the correct url
Specification needed on what the correct behaviour should be (see #344), but in any case it's not "crash"