Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Algolia status comparison endpoint #569

Open
hinzed1127 opened this issue Sep 26, 2024 · 0 comments
Open

Fix Algolia status comparison endpoint #569

hinzed1127 opened this issue Sep 26, 2024 · 0 comments
Labels
bug Something isn't working lower priority

Comments

@hinzed1127
Copy link
Contributor

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:

  • children gets calculated in loadPageMetadataMap, 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 children from 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's children array
      • If the new parent value is not null, remove the current page from the old parent and add it to the new parent's children array
    • 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.

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 recordIds and resets all of those (i.e., this is the middle ground between a wholesale reset and an endpoint that can only reset individual records)

More recent issues

internalRedirect and externalRedirect appear to suffer from a similar null value issue, but the cause still needs to get diagnosed.

@hinzed1127 hinzed1127 added bug Something isn't working lower priority labels Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lower priority
Projects
None yet
Development

No branches or pull requests

1 participant