Open rekt-hard opened 2 months ago
is this a bugfix or a feature?
Bugfix. It is only about making sure the values exist before performing a lookup or trying to parse it.
For example, performing the following steps will lead to an error:
https://127.0.0.1:5000/records/<draft-id>/export/json-ld?preview=1
I will just create an issue out of this
would it not be better to use a try except block?
try:
resource_type_id = obj["metadata"]["resource_type"]["id"]
except KeyError:
return missing
or is the "resource_type.id" always there? the same could be applied to the other changes as well
Right - good catch. Not sure about it being there.
In other places something like this is used: resource_type_id = py_.get(obj, "metadata.resource_type.id")
(which will return None
if any intermediate attribute is not available)
Would go for that.
This PR was automatically marked as stale.
:heart: Thank you for your contribution!
Description
Perform resource type vocabulary lookup only if resource type is set. Parse dates only if they are set
Checklist
Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:
Third-party code
If you've added third-party code (copy/pasted or new dependencies), please reach out to an architect.
Reminder
By using GitHub, you have already agreed to the GitHub’s Terms of Service including that: