fix(doc): handle ignored errors without span (e.g. missing optional roots)#455
fix(doc): handle ignored errors without span (e.g. missing optional roots)#455
Conversation
Affects: - BLOG_ROOT - CONTRIBUTOR_SPOTLIGHT_ROOT - CURRICULUM_ROOT - GENERIC_CONTENT_ROOT
|
67f285c was deployed to: https://rari-pr455.review.mdn.allizom.net/ |
18346ed to
7c0af70
Compare
7c0af70 to
a6b343d
Compare
|
@LeoMcA I have now:
I verified this by commenting out I compared the result between % jd issues-*.json
@ [""]
- [{"col":0,"end_col":0,"end_line":0,"fields":[["message","No generic content config found"]],"file":"","ic":0,"ignore":true,"line":0,"req":0,"spans":[]}] |
crates/rari-doc/src/issues.rs
Outdated
|
|
||
| if !issue.ignore { | ||
| // Record first. | ||
| event.record(&mut issue); | ||
| } | ||
|
|
||
| if !issue.ignore { | ||
| // Check again after recording. |
There was a problem hiding this comment.
Actually I was wrong in my comment wasn't I: this should already be only recording issues with ignore = false: so I'm not sure what this change does, unless event.record mutates issue.ignore? If so we should leave a comment explaining that, and see if wrapping event.record in the if statement is necessary.
There was a problem hiding this comment.
At first, this was a bit confusing for me as well, but here's what I think is happening:
The on_event() handler creates a new Issue where ignore is set to false:
rari/crates/rari-doc/src/issues.rs
Lines 167 to 175 in d51f68b
Then ignore is set to true only if we have a span with IssueEntries that has entry.ignore = true:
rari/crates/rari-doc/src/issues.rs
Lines 205 to 207 in d51f68b
However, warn!(ignore = true, "{e}") only creates an event, not a span, so it isn't covered by this.
The event.record() call causes the Visit implementation for Issue (not IssueEntries) to be called, which sets ignore to true if the Issue has a field named ignore:
rari/crates/rari-doc/src/issues.rs
Lines 112 to 132 in d51f68b
I verified this behavior now by adding eprintln!() statements where ignore is set (869f673):
% cargo run --quiet build -f ../content/files/en-us/web/http/guides/browser_detection_using_the_user_agent/index.md --issues ./issues.json 1 ↵ ✭
Building everything 🛠️
Took: 8.858ms for reading 1 docs
Setting Issue.ignore = true (issue: Issue { req: 0, ic: 0, col: 0, line: 0, end_col: 0, end_line: 0, file: "", ignore: true, fields: [("message", "No generic content config found")], spans: [] })
Took: 336.059ms to build spas (111)
Took: 783.511ms to build content docs (1)
Took: 36.093ms to build search index
I will update the comments to better explain this.
This reverts commit 869f673.
Makes it clear that this only applies to Events with a span.
Description
Suppress errors for missing optional roots:
Motivation
Prevent these from showing up in content PRs like this one.
Additional details
Related issues and pull requests