Keep Partial Product Updates From Erasing Good 2scraper Catalog Data
A sparse update and a full replacement need different rules, even when both contain the same product ID.

From the 2scraper catalog I might choose one project for an authorized full export and keep a smaller local update feed for fields I can refresh independently. They can both describe the same product without carrying the same columns. An importer committed to replacing the whole row can erase a previously observed name or price as soon as the partial update arrives. The first design choice is to say whether each input describes a complete record or a change to one.
Written with AI assistance. The catalog records and amounts below are synthetic. The Python fixture was run locally.
Give every ingestion route an explicit contract
A full snapshot is a description of the record under the source's declared shape. A patch is an instruction to change a limited set of fields. When the two are mixed inside one normalized data store, I would preserve their intent in a record type rather than reconstruct it from the number of fields present. A snapshot with a missing required field may need review. A partial update that omits the same field can be legitimate if the patch never claimed to describe it.
The source adapter can have a short table listing each normalized field, its raw source, whether absence is allowed, and what an explicit null means. Do not assume every source uses null the same way. In one feed it could represent an explicitly unavailable amount. In another it might be a placeholder inserted automatically when no value could be read. A reviewed adapter should map those cases to the documented state before it asks the storage layer to merge them.
I would keep the import identity and the source revision available as part of the stored observation. The name of a repository or a file extension does not establish the schema for every mode and version. The project catalog is a place to find the source and its documented outputs. Validate the actual field list for the pinned version you use. The sample in this article defines a small downstream patch contract and makes no claim that any individual exporter emits this shape.
Try a small update that changes just one thing
The local fixture starts with a complete profile for a fictional desk tray. It then updates stock status while leaving the name and amount untouched. In another operation a known price is explicitly cleared. Because that action is allowed for price under the sample contract, the current price becomes unavailable. The model stores where each currently held value came from. A consumer can tell which fields are current from an update and which were carried from the full snapshot.
FIELDS = {"name", "price", "in_stock"}
CLEARABLE = {"price"}
def merge(record, patch):
if patch["item"] != record["item"] or patch["version"] <= record["version"]:
raise ValueError("unexpected item or out-of-order revision")
changes = patch["fields"]
if changes.keys() - FIELDS:
raise ValueError("unknown field")
if any(value is None and key not in CLEARABLE for key, value in changes.items()):
raise ValueError("only approved fields may be cleared")
return {
"item": record["item"],
"version": patch["version"],
"fields": {**record["fields"], **changes},
"source": {**record["source"], **dict.fromkeys(changes, patch["evidence"])},
}
start = {
"item": "A-007", "version": 1,
"fields": {"name": "Desk tray", "price": "12.50", "in_stock": True},
"source": dict.fromkeys(FIELDS, "full-1"),
}
stock = {"item": "A-007", "version": 2, "fields": {"in_stock": False}, "evidence": "stock-2"}
clear = {"item": "A-007", "version": 3, "fields": {"price": None}, "evidence": "review-3"}
mid = merge(start, stock)
end = merge(mid, clear)
assert mid["fields"] == {"name": "Desk tray", "price": "12.50", "in_stock": False}
assert end["fields"]["price"] is None
assert end["source"] == {"name": "full-1", "price": "review-3", "in_stock": "stock-2"}
assert start["fields"]["price"] == "12.50"
print("Stock updated; price cleared by its own evidence; name preserved")
The local run printed Stock updated; price cleared by its own evidence; name preserved. It demonstrates three separate outcomes rather than treating every empty-looking field as an instruction. The original amount remains in the original observation. The current view says the field was explicitly cleared by a later approved input. Both records remain meaningful because they have separate evidence.
Decide which nulls actually clear a value
An empty source value may mean no observation. Clearing the current value is a separate decision. Suppose a first feed records a valid price of 12.50, and a second feed's report has no priced row because it only collects stock. The latter has no evidence about price. Omitting the field from its patch is the right representation. If a later approved record explicitly says the price is unavailable, the report can clear the field and preserve the reason.
Some fields may never allow an unconditional clear. A name can remain valid to identify the product even when a price becomes unavailable. A product ID belongs to the identity contract and changing it may need a different operation entirely. I would test a patch that tries to clear a protected field and verify that the previously published row remains unchanged. A validator that raises after updating other fields has still left an inconsistent result.
If the reading experience needs more detail, display last known amount and current availability as separate fields. Someone reviewing a catalog might want the last known price for context without believing it applies today. Give the value its original timestamp and the appropriate evidence label. This preserves useful history while keeping a current comparison from including an amount that the approved view no longer considers available.
Keep application order visible when two updates touch one field
The sample uses an increasing version for a single product. In production, decide whether different sources can issue independent updates, whether versions are comparable across those sources, and which source is authoritative for each field. A patch from one source may be entitled to change stock but not the approved title. Keeping ownership on the mapping layer avoids letting whichever file arrives last become the authority for all fields.
Try a late-arrival case. The approved version changes the stock flag from true to false. An older stock update arrives afterward and says true. If the input contract treats it as an outdated revision, it should not overwrite the newer approved view. Retain the older record for audit as appropriate, classify it, and preserve the published state. If your collection does not supply a reliable version, an arrival timestamp is not necessarily evidence of source order. Decide how to hold conflicting records until a reviewer can establish which applies.
Two independent field updates may be safe to combine even when their arrival order differs. Test at least one such case before designing a general merge. A global revision for the whole row can reject a legitimate, independent update if the business policy expects field-level precedence. A field-specific policy brings more complexity, so document why it exists and where an update can conflict. The sample deliberately chooses the simpler one-product revision contract.
Verify that a full import still replaces what it owns
The reverse problem arises when the importer treats every source as a patch. It can retain fields from a much older product record even after the contract says a new full snapshot is authoritative. That may make the current row look richer while mixing observations from unrelated reporting periods. A full snapshot can replace a precisely defined set of fields and explicitly retain separately owned enrichment. The boundary should be part of the schema, rather than an accidental side effect of how dictionaries are merged.
For a worked review, start with a full observation containing name, price, and stock. Add an independently reviewed field such as a local catalog grouping that lives outside the source-owned columns. Load a newer full observation with a different amount and stock state. It should replace the source-owned values under the approved rule while leaving the locally reviewed grouping associated with that product. A subsequent stock-only update should change stock and leave the other fields alone.
The integration test should assert both the direct values and source provenance. After a new full import, the name and amount should identify the approved full input even if their displayed values happen to remain unchanged. After the stock-only update, those fields should retain their source reference. That is the evidence a reviewer needs to distinguish a confirmed new observation from an older value carried forward.
Explain coverage in the report readers actually use
A catalog can contain a surprising mixture of recent rows and old fields. A report that labels the entire product with the time of its latest update can make every displayed value seem fresh. If the last patch only touched stock, the amount may be from an earlier observation. For a price decision, freshness belongs to the price input. For an availability decision, use the stock observation instead. Add a timestamp or version field where that distinction affects interpretation.
Consider a synthetic run with 50 referenced products and only 40 current usable amounts. A stock patch arrives for five of the remaining items. The catalog can now say something new about their availability, but it still has 40 prices. A dashboard that treats every recently updated row as newly priced would overstate coverage. Count products with a recent stock observation separately from those with a usable price, and document how each metric treats unavailable or stale values.
I would also track strictly held updates. A patch might be rejected because it tries to change an unrecognized field, references the wrong product, or is out of order. Those observations have different owners. The reason counts can help locate whether the publisher, mapping layer, or downstream storage needs attention. Keep the original approved catalog readable during a failed import and show why the candidate is pending.
Test the reader as well as the merge function
Run a fixture through the normal path used to publish the downstream report. Feed the initial record, the stock-only patch, and the explicit clear. Verify that the report still displays the name, updates availability, and treats the known-cleared price as unavailable. Then submit a bad patch with a protected field clear. The previous approved state should remain visible and an authorized operator should receive a reason that makes the repair clear.
For the next release, add an unchanged replay and a conflicting revision. The toy function rejects a repeated version. A production queue might accept an exact replay as harmless if it compares against the original approved record. Pick the behavior deliberately and check that a different value for the same revision cannot silently replace the prior one. A workflow-level test catches conflicts that might be hidden if a test only exercises field merging in memory.
Finally, show one reader an approved row and ask them to explain which source supplied each value. If the row looks complete but nobody can say which parts were directly observed and which were carried forward, add the missing evidence to the report design. A good merge preserves the history that explains the current catalog. It gives teams a way to use partial data without letting a sparse file erase useful observations.
Start with a deliberately sparse sample
Pick one listing export you have permission to use, then make a local patch containing only one known field. Review the exported schema, define which explicit nulls are allowed to clear a stored value, and run the fixture before putting the changes into a live catalog. The 2scraper project catalog can help you choose an export with the documented fields your report needs. Use its exact source shape as the starting point for your adapter, then verify the merge against the small, independently checked example.
Further reading
Keep a Catalog Export’s Column Order Stable Across App Releases shows how to protect a downstream consumer when the output shape changes.
A Valid 2scraper Export Can Still Be Wrong for Your Report explains how to check whether a structurally valid input supports the report's actual requirements.
Show How Much One Observation Can Move a CaptchaTheCat Summary. It shows how omissions show up later in a published summary.
Stop Collecting Data Manually: Discover a Smarter Way to Work with the Web Using 2scraper
2Scraper — How to Collect Website Data Without Copying Pages by Hand
2scraper: How to Build Practical Web Data Pipelines Without Writing Every Scraper from Scratch
Keep a 2scraper Basket Index Comparable When a Product Changes
Reject Colliding Header Aliases Before Reading a 2scraper CSV
Comments
Join the discussionNo comments yet. Be the first to comment.





