Repository navigation
Let a JSON API source quote several fields (#179, item 2) - #189
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>
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
5 similar comments
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
|
Claude encountered an error after 1s —— View job I'll analyze this and get back to you. |
|
Claude finished @caufieldjh's task in 47s —— View job PR review: JSON API source quoting several fields (#179, item 2)
SummaryThis is a clean, small change. The best choice here is reusing On the design choice you raised (
|
A source whose JSONPath did not parse still loaded, and lost its line at fetch time; a config built in Python skipped every check. The field check now also parses each path, lives in models as json_api_field_problem, and runs from JSONAPISourceConfig.__post_init__ as well as the YAML loader, which still turns a problem into a warning and a skipped source. Also pins the type of a record whose only text is source_extra_fields (the source's default, as DOI and PMID do), and documents how a single-path content reads a list or blank value differently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. All five points are addressed in 1c8bfbc.
The PR description's validation bullet is updated to match. Locally after the change: 100 targeted tests pass, |
|
Claude finished @caufieldjh's task in 46s —— View job PR review: JSON API source quoting several fields (#179, item 2): follow-up after 1c8bfbc
SummaryThe new commit deals with every point from the last review:
The checks now live in one place in Points to consider
Code quality
Performance / security
Test coverageThere are 24 tests in
One more test could pin point 1: a single-string field with an invalid path (e.g. VerdictReady to merge from my side. Point 1 is worth noting in the changelog; the rest are optional nits. |
…view) The loader ran json_api_field_problem and the content_type check, then __post_init__ ran both again. It now builds the config and turns the ValueError into its warning, so YAML and code meet one set of rules. Adds a test that a bad single path is now refused, documents that change, and says to point each path at a value rather than an object. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @caufieldjh's task in 25s —— View job PR review: JSON API source quoting several fields (#179, item 2): follow-up after 113af64
What changed since the last review
Notes on the new code
Performance / securityNothing new. Each path is now parsed once at load instead of twice. Test coverageThe rejection cases now go through both the YAML loader and the in-code dataclass for:
I have no further gaps to suggest. VerdictEvery point from both earlier reviews has been dealt with. I have no blocking or non-blocking issues left, so this looks ready to merge from my side. |
|
Follow-up points, in 113af64:
Locally: 101 targeted tests, |
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, and every JSONPath must parse. The check (json_api_field_probleminmodels.py) runs inJSONAPISourceConfig.__post_init__, so a config built in code raisesValueError. The YAML loader builds the config and turns thatValueErrorinto a warning that skips the source, so one set of rules covers both. An unknowncontent_typeis treated the same way.Behaviour change (for release notes)
A configured JSON API source with an invalid JSONPath in any field (including single-path
title,yearand the rest) is now skipped at load with a warning naming the path, and that prefix is unavailable until the path is fixed. Before, such a source loaded, and only that field came back empty. Building aJSONAPISourceConfigwith such a path in Python now raisesValueError.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