Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jmespath exclude_empty fix #372

Merged
merged 1 commit into from
Jan 2, 2025
Merged

jmespath exclude_empty fix #372

merged 1 commit into from
Jan 2, 2025

Conversation

DylanWelzel
Copy link
Contributor

@DylanWelzel DylanWelzel commented Dec 30, 2024

A KeyError was being raised in the transformation logic whenever a list item did not contain the target_field. In particular, this occurred when making a query to mychem.info with jmespath_exclude_empty=true, causing the transformation step to attempt dictionary access on a missing key.

curl --location --globoff 'https://mychem.info/v1/query?size=1000&fields=drugcentral.bioactivity%2Cdrugcentral.xrefs.umlscui%2Cdrugcentral.synonyms&jmespath_exclude_empty=true&always_list=drugcentral.bioactivity&jmespath=drugcentral.bioactivity%7C[%3F!action_type%20%20%26%26%20length(uniprot[%3Funiprot_id%3D%3D%27P29274%27])%20%3E%20%600%60]' \
--header 'Content-Type: application/json' \
--data '{
    "q": ["P29274"],
    "scopes": "drugcentral.bioactivity.uniprot.uniprot_id"
}'

This query would raise a KeyError: 'bioactivity' if any list item did not include "bioactivity" as a key.

See #368

@DylanWelzel DylanWelzel requested a review from newgene December 30, 2024 21:22
@newgene newgene merged commit a2201a2 into 1.0.x Jan 2, 2025
1 check passed
@newgene newgene deleted the exclude-empty-fix branch January 2, 2025 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants