Repository navigation
Conversation
A row holding one invalid stored value, such as an unknown mm, an oversized ext, inserter, matcher or UID, or a malformed partner record, failed to load whole. Read optional EID and UID fields that this build rejects as absent, skip other invalid UIDs and unreadable entries or records individually, and log a count of each kind of skip. The admin EC lookup builds its auction view the same way.
|
For #1532's rename of the native Geo profile variable to No file in this PR uses the old name after the merge, so it only takes the rename from #1641. The merge had no conflicts. Correction: through #1566, this merge also carries five #1540 commits that #1566 had not merged before (CloudFront forwarding authentication, AWS ingress and Terraform demo prerequisites, the example deployment gate and the deployment guide). It is not only the rename. |
prk-Jr
left a comment
There was a problem hiding this comment.
Summary
Reads now skip each invalid stored EID value alone and keep the rest of the row, while top-level fields (consent, geo, opt-outs) still fail closed. Both production readers (the KV read and the admin lookup) call drop_unreadable_ids, validate refuses to write back a placeholder for an unreadable record, and the write planner compares rows only after the read bookkeeping is taken, so skipped values are dropped from storage only alongside a real change. Approving; the items below are non-blocking.
Non-blocking
♻️ refactor
- The admin lookup's lenient read has no test —
crates/trusted-server-core/src/ec/admin.rs:409. Deletingentry.drop_unreadable_ids();there leaves everyec::test passing. Without it, a row holding one unreadable record shows "entry failed validation" and no auction view in the admin lookup, although the auction read succeeds. This test, added besidevalid_json_with_invalid_entry_schema_remains_visible, passes on this PR and fails with that line removed:
#[tokio::test(flavor = "current_thread")]
async fn lookup_leaves_unreadable_record_out_of_auction_view() {
let ec_id = test_ec_id();
let body = serde_json::json!({
"v": crate::ec::kv_types::SCHEMA_VERSION,
"created": 1,
"consent": { "ok": true, "updated": 1 },
"geo": { "country": "US" },
"ids": {
"broken.example.com": { "uid": 5 },
"ssp_y": { "uid": "kept" }
}
})
.to_string();
let kv = kv_with_raw_body(&ec_id, &body).await;
let req = get_request(&format!("/_ts/admin/ec/{ec_id}"));
let response = handle_admin_ec_lookup(Some(&kv), &test_registry(), &req)
.await
.expect("should handle lookup");
let json = response_json(response);
assert!(
json.get("entry_error").is_none(),
"should read the row without the unreadable record"
);
assert!(
json.get("auction").is_some(),
"should build the auction view from the readable records"
);
assert_eq!(
json["entry"]["ids"]["broken.example.com"]["uid"], 5,
"should still show the stored row unchanged"
);
}🤔 thinking
- The admin lookup discards the
ReadSkipsit gets —crates/trusted-server-core/src/ec/admin.rs:409. The auction view then lacks a partner record or UID with nothing saying so, and an operator has to diff it against the rawentry. Returning the counts and removed record names in the lookup payload would make the view explain itself.
⛏ nitpick
ReadSkips::recordsduplicatesremoved.len()—crates/trusted-server-core/src/ec/kv_types.rs:198. Two public fields are kept in step only byskipped.records = skipped.removed.len(); arecords()method returningremoved.len()would remove the chance of them disagreeing.
📝 note
- Merge conflict with the moved base.
feat/record-backend-edgezerohas moved since this PR last merged it, and the PR now conflicts inCHANGELOG.mdonly. The base commits since then don't touchkv_types.rs,kv.rsoradmin.rsand add no new stored-row reader. CI will need to run again after the base is merged in.
CI Status
All 28 checks reported at 179ae8a4 pass.
ChristianPavilonis
left a comment
There was a problem hiding this comment.
The lenient reader keeps valid neighbors in the ordinary cases I tested, and malformed consent or geo still blocks the read and write. I'm requesting changes because a malformed legacy UID can cause valid provider EIDs to be erased on the next unrelated write.
I ran 689 existing EC tests, eight focused probes on this head, and two probes on the merge base. The focused checks used the core admin route and KV code with an in-memory store. The live feat/record-backend-edgezero branch also conflicts in CHANGELOG.md; I did not test a conflict-resolved merge.
| /// entry is skipped alone. | ||
| #[derive(Deserialize)] | ||
| struct StoredPartnerId { | ||
| uid: String, |
There was a problem hiding this comment.
P1: Don't let a malformed legacy UID discard valid provider EIDs. I tested a missing uid and a non-string uid in a record with a valid provider EID. Both reads dropped the whole partner, and an unrelated partner upsert persisted that loss. The baseline rejected the same rows without writing them. The spec says modern readers ignore the legacy mirror when eids is non-empty. Can we require a valid mirror only for legacy records and rebuild it from a surviving provider UID? Keep the safeguard against falling back to the stale mirror when all provider UIDs are unreadable.
| Ok(entry) => { | ||
| Ok(mut entry) => { | ||
| payload.tombstone = Some(!entry.consent.ok); | ||
| // Matches the auction read, which leaves out what it |
There was a problem hiding this comment.
P2: Don't gate the auction preview on the raw display parse. I reproduced this through the mounted route with an over-deep ext and an out-of-range mm. The production read dropped only the invalid field and kept the UID eligible for auction, but the outer JsonValue parse failed here, so admin omitted auction. That omission is documented to mean no KV-derived EIDs would be attached. Run the typed read independently of rendering the raw entry, and keep the raw-display error separate from the auction result.
| )] | ||
| expiry: Expiry, | ||
| #[serde(default)] | ||
| refresh: Option<KvRefresh>, |
There was a problem hiding this comment.
Policy question: Should a missing refresh time discard the UID? I confirmed that an otherwise valid UID with a valid hard expiry is skipped when refresh.from is missing. The storage spec in §6.3 says to keep the UID and drop only refresh state when no time is stated. Should this read follow that rule, or is dropping the UID intentional? If intentional, please update the spec to distinguish stored reads from provider ingest.
| skipped.eids += 1; | ||
| return None; | ||
| }; | ||
| let uids: Vec<KvUid> = stored |
There was a problem hiding this comment.
P3: Count EIDs that arrive with an empty uids array. With uids: [] next to a valid sibling EID, cleanup drops the empty entry but reports zero skips, so the KV reader emits no warning. I verified this with captured logs. The drop predates this PR; the gap is in the new counters. Count entries that arrive empty here and leave the existing rule for entries emptied by already-counted UID skips.
| let uids: Vec<KvUid> = stored | |
| if stored.uids.is_empty() { | |
| skipped.eids += 1; | |
| return None; | |
| } | |
| let uids: Vec<KvUid> = stored |
| payload.tombstone = Some(!entry.consent.ok); | ||
| // Matches the auction read, which leaves out what it | ||
| // cannot read; `entry` above still shows the stored row. | ||
| entry.drop_unreadable_ids(); |
There was a problem hiding this comment.
P3: Explain dropped partners in auction.skipped. I seeded a malformed partner beside a valid one. The admin route kept the bad record visible in entry but returned neither an entry_error nor a skip reason for that partner. The API guide says auction.skipped explains filtered IDs. Can we use the removed source keys from ReadSkips to report an unreadable reason without changing the stored JSON view?
Summary
mm, anext,inserterormatcherover a lowered limit, a bad UID, or a malformed partner record. Only an oversized UIDidwas tolerated, and a UID skipped inside a record that was kept was neither logged nor counted (Lenient KV reader for unknown or invalid stored fields #1554, from the Collect server-side identity provider EIDs in a single page-load write #1487 review).feat/record-backend-edgezero), the lowest branch with the currentec/kv_types.rs. Run Axum identity through the shared application #1646 and Enforce provider opt-outs and legacy EID expiry on Fastly and Axum #1626 carry the same file.Changes
crates/trusted-server-core/src/ec/kv_types.rsKvPartnerIdgets a lenientDeserializethrough rawStoredPartnerId,StoredEidandStoredUidshapes. An invalidmm,ext,inserterormatcherreads as absent. Any other invalid UID (blank or oversizedid, negative or missingatype, badowner,exporrefresh) is skipped. An EID entry or partner record that cannot be read, or has no readable UID left, is flagged unreadable.drop_unreadable_idsremoves flagged records and returnsReadSkipscounts.validaterejects a flagged record, so a placeholder is never written back. ReplacesKvEidRepranddeserialize_readable_uids. Tests cover each invalid value next to a valid record, round-trip without the skipped values, and the placeholder guard.crates/trusted-server-core/src/ec/kv.rsReadSkipscounts. Test throughdeserialize_entry.crates/trusted-server-core/src/ec/admin.rsentryJSON is unchanged.docs/superpowers/specs/2026-10-30-s2s-eid-collection-design.mdCHANGELOG.mdCloses
Closes #1554
Spec
Spec: not a new feature. This follows the read-tolerance direction in the s2s EID collection spec, which deferred lenient readers to #1554. §6.3 of that spec is updated.
Test plan
cargo test-fastly && cargo test-axum(Fastly suite 4209 passed; Axum 114 passed)cargo clippy-fastly && cargo clippy-axumcargo fmt --all -- --checkcd crates/trusted-server-js/lib && npx vitest run(no JS changes)cd crates/trusted-server-js/lib && npm run format(no JS changes)CHANGELOG.mdcargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1fastly compute servecargo test-cloudflare(70 passed),cargo test-spin(90 passed), CLI tests (970 passed),clippy-cli. Removing the unreadable-record flag makesunreadable_stored_record_is_skipped_alonefail.Notes for review
v, consent, geo, publisher properties, opt-out maps) still fail the read closed. Skipping consent or geo would not be safe.Checklist
unwrap()in production code — useexpect("should ...")logmacros (notprintln!)