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

🔨 correctly initialize bugsnag in SiteBaker v2 #4005

Merged
merged 4 commits into from
Oct 9, 2024
Merged

Conversation

ikesau
Copy link
Member

@ikesau ikesau commented Oct 3, 2024

Fixes #3019

I wasn't able to re-open the original PR for this branch because I rebased the branch after the PR had been closed by Stalebot.

tl;dr: - it was tricky to robustly fix all the errors and warnings currently in prod with code. We'll be able fix some of them by updating the data and can ignore the rest in bugsnag.

In the other PR, I had proposed 3 ways to fix the existing errors that initializing bugsnag correctly would begin to expose:

  1. Gdoc explorer link validation should check for redirects
  2. The missing tags warnings shouldn't be logged
  3. The (current) missing author errors should be ignored in bugsnag

Each had a sort of problem.

For 1: I added code that considers redirects, but the coronavirus-data-explorer redirect is hardcoded in the baker/redirects.ts file and can't be easily imported to use in gdocs validation. We could ignore all these errors, or update and republish the articles that use the old URL.

For 2: we don't really have a good way to exclude a certain class of error/warning from Bugsnag because we don't have error codes. We can't ignore all warnings, because there are some warnings that we do want to be notified about such as a linked gdoc no longer existing, which we can't upgrade to errors because that prevents a gdoc from being published.

For 3: all validation errors for a gdoc were being serialized together and logged, which would mean that an ignored error might resurface if its gdoc acquired another type of error. I've fixed this by logging each error/warning to bugsnag individually.

@@ -750,6 +751,8 @@ export class GdocBase implements OwidGdocBaseInterface {
const chartIdsBySlug = await mapSlugsToIds(knex)
const publishedExplorersBySlug =
await db.getPublishedExplorersBySlug(knex)
const redirects = await getRedirectsFromDb(knex)
const resolvedRedirects = resolveRedirects(redirects)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we call validate on every gdoc in a loop when baking, which means we'd make the same query many times. We could move the logic to a separate function and make the query (and resolve redirects) only once.

Similarly for other DB queries we make here, but that is out of scope.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, though refactoring gdocs to validate in bulk would probably be best done in a separate PR.

As is, I've decided just to not do this validation - we've never changed an explorer to point to another explorer (except with coronavirus-data-explorer) so I think if it comes up again, we can just update the (likely fewer than 10) gdocs that are affected.

@@ -16,6 +16,29 @@ export async function getRedirects(
)
}

/**
* Takes a list of redirects and returns a map of source -> target
* such that if you have [A -> B, B -> C], the map will be { A -> C, B -> C }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought there were no redirect chains in the DB. We have a validation that prevents adding new chains, and if there are any existing, it would be better if we resolved/changed them in the DB instead of always resolving them here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! I had some leftover testing data in my redirects table it seems. Not that it matters now that I've removed the explorer validation 🙂

@owidbot
Copy link
Contributor

owidbot commented Oct 8, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-bugsnag-init

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-10-08 22:35:26 UTC
Execution time: 1.14 seconds

@rakyi rakyi self-requested a review October 9, 2024 08:59
@ikesau ikesau merged commit d21f869 into master Oct 9, 2024
25 checks passed
@ikesau ikesau deleted the bugsnag-init branch October 9, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate and improve error reporting for baking (e.g. missing DoDs)
3 participants