Repository navigation
Let a JSON API source quote several fields (#179, item 2) - #189
Open
caufieldjh wants to merge 1 commit into
Open
caufieldjh wants to merge 1 commit into
caufieldjh wants to merge 1 commit into
Conversation
content took one JSONPath and kept its first match, so facts spread across a record (openFDA's device_class and regulation_number) could not be quoted. content may now also be a list of JSONPaths, one value per line, or a mapping of labels to JSONPaths, one "Label: value" line each. Each path is read as source_extra_fields reads one, and an empty value leaves no label behind. A list or mapping is a record, not an abstract, so it is cached as full_text: a failed quote no longer says "only abstract available". A single path stays abstract_only. A new content_type key overrides either. source_extra_fields is now honoured for a configured source's prefix, and a source with a malformed fields entry or content_type is skipped at load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
3 similar comments
Contributor
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
Contributor
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
Contributor
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses item 2 of #179. Item 1 (XML via
url:) landed in #188. The third ask in the issue comments, a non-JSON source built from a URL template, is not in this PR.Problem
A configured JSON API source's
contenttook one JSONPath and kept only its first match. Facts spread across a record, such as openFDA'sdevice_classandregulation_number, never reached the cached text and could not be quoted. A JSON-derived record was also always labelledabstract_only, so a failed quote carried a misleading "only abstract available" note. This is the same mislabelling #164 fixed for Wikipedia.Change
contentmay be a list or a labelled mapping, not just one JSONPath:Label: valueline per field, in order. A list gives bare values, one per line. Each path is read throughextract_extra_fields, the same readersource_extra_fieldsuses: first match only, a list value's items joined with spaces, and an empty value left out, label included. A single-pathcontentis unchanged.content_type: a list or mapping defaults tofull_text, since a record isn't an abstract. A single path staysabstract_only, as before. A new optionalcontent_typekey (abstract_only|full_text) overrides either default.source_extra_fieldsis now honoured for a configured source's prefix. Its fields are appended under### nameheadings and recorded inextra_fields_captured, as for DOI, PMID and ClinicalTrials.contenttakes a list or mapping. A source with any other malformedfieldsentry, or an unknowncontent_type, is skipped with a warning, so it fails at load rather than during a fetch.Design choice to review
The
full_textdefault for list and mapping content is a judgement call. The alternative is no default: list and mapping forms would stayabstract_onlyunlesscontent_type: full_textis set, and the FDA example would then show the misleading abstract note unless configured.Cache
No cache version bump. An entry already cached keeps its text. After changing a source's
fields,cache reference PREFIX:ID --forcerefetches it. This was checked live: a single-path EBF entry was rewritten with the labelled lines asfull_text. The docs say so.Tests
tests/test_json_api_multiple_fields.py(new) uses the real openFDA EBF record (tests/fixtures/json_api/, fetched 2026-11-30, with theopenfdalists cut to 3 entries). It covers:sources:in the main config filecontent_typevalidationcontent_typedefaults and overridesource_extra_fields: appended, alone, and for another prefixfind_text_in_referencefor each field, served from the cachetests/test_json_api_source.py(30 tests) is unchanged and passes.just doctest(351),just mypyandjust format.test_wikipedia_source.pyfails on and off on my machine with connect timeouts to its own127.0.0.1test server.wikipedia.pyis untouched; I'm leaving that to CI.Device class: 2andRegulation number: 872.3690are valid.Device class: 3is invalid, with no abstract note.Docs
docs/how-to/add-reference-source.mdhas a new "Quoting several fields" section, and its config table listscontent_type.🤖 Generated with Claude Code