-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The Problem
The status endpoint is a quick "health-check" endpoint that doesn't get functionally used by the site, but is purely for monitoring purposes. It is a quick way to view and discrepancies between Contentful data and the Algolia index.
There appears to be a handful of keys right now that are creating false mismatches between Contentful and Algolia, either due to some edge cases in null values not being caught properly, or quirks of what does or doesn't get shown as changed when the Contentful webhook gets fired that our update Algolia endpoint is the recipient of.
Technical causes
Reason why the children key mismatch keeps happening:
childrengets calculated inloadPageMetadataMap, which only gets the latest value when initially adding a new page to the map. When a page removes or changes its parent, that only triggers an update in the algolia index for that page, not the parent whose children are changing.- Solution 1: remove
childrenfrom the Algolia records entirely - Solution 2: when updating the parent for a record, also do the following:
- If new parent value is
null, then simply remove the current page from the old parent page'schildrenarray - If the new parent value is not
null, remove the current page from the old parent and add it to the new parent'schildrenarray
- If new parent value is
- Solution 2 is more effort and doesn't gain us anything at this time. Therefore, it probably makes sense to just quickly do solution 1 as a one-off solution.
- Solution 1: remove
Reason why the metaTitle and metaDescription mismatch keeps happening (I think):
- The contentful webhook only includes defined values in updates it pushes out. Therefore, if a value is removed, it doesn't get included in the payload.
- When comparison then happens in the SvelteKit API endpoint, it gets skipped entirely
- Solution: make sure we explicitly check for those fields, as we should always be expecting them
- Add-on to that solution: also include a "reset" endpoint for individual records, and not just a wholesale reset
- Alternatively, make a reset endpoint that accepts an array of
recordIdsand resets all of those (i.e., this is the middle ground between a wholesale reset and an endpoint that can only reset individual records)
- Alternatively, make a reset endpoint that accepts an array of
More recent issues
internalRedirect and externalRedirect appear to suffer from a similar null value issue, but the cause still needs to get diagnosed.