Skip to content

fix(doc): handle ignored errors without span (e.g. missing optional roots)#455

Merged
LeoMcA merged 8 commits intomainfrom
suppress-optional-root-errors
Jan 19, 2026
Merged

fix(doc): handle ignored errors without span (e.g. missing optional roots)#455
LeoMcA merged 8 commits intomainfrom
suppress-optional-root-errors

Conversation

@caugner
Copy link
Contributor

@caugner caugner commented Dec 19, 2025

Description

Suppress errors for missing optional roots:

  • BLOG_ROOT
  • CONTRIBUTOR_SPOTLIGHT_ROOT
  • CURRICULUM_ROOT
  • GENERIC_CONTENT_ROOT

Motivation

Prevent these from showing up in content PRs like this one.

Additional details

Related issues and pull requests

Affects:
- BLOG_ROOT
- CONTRIBUTOR_SPOTLIGHT_ROOT
- CURRICULUM_ROOT
- GENERIC_CONTENT_ROOT
@caugner caugner requested a review from a team as a code owner December 19, 2025 16:15
@caugner caugner requested a review from LeoMcA December 19, 2025 16:15
@github-actions
Copy link
Contributor

github-actions bot commented Dec 19, 2025

67f285c was deployed to: https://rari-pr455.review.mdn.allizom.net/

@caugner caugner marked this pull request as draft January 15, 2026 15:29
@caugner caugner changed the title chore(doc): suppress errors about missing optional roots chore(doc): ignore errors about missing optional roots Jan 15, 2026
@caugner caugner force-pushed the suppress-optional-root-errors branch from 18346ed to 7c0af70 Compare January 15, 2026 16:54
@caugner caugner force-pushed the suppress-optional-root-errors branch from 7c0af70 to a6b343d Compare January 15, 2026 16:57
@caugner
Copy link
Contributor Author

caugner commented Jan 15, 2026

@LeoMcA I have now:

  1. Extracted a capture_doc_error() helper function that emits a warning, and sets the ignore = true flag for optional missing root errors.
  2. Fixed the issue recording logic.

I verified this by commenting out generic_content_root in my .config.toml, then running:

cargo run build -f ../content/files/en-us/web/http/guides/browser_detection_using_the_user_agent/index.md --issues ./issues.json

I compared the result between main and this branch, and the "unknown" issue is no longer in the issues.json in this branch:

% 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":[]}]

@caugner caugner requested a review from LeoMcA January 15, 2026 17:32
@caugner caugner marked this pull request as ready for review January 15, 2026 17:32
Comment on lines +215 to +222

if !issue.ignore {
// Record first.
event.record(&mut issue);
}

if !issue.ignore {
// Check again after recording.
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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:

let mut issue = Issue {
req: 0,
ic: -1,
col: 0,
line: 0,
end_col: 0,
end_line: 0,
file: String::default(),
ignore: false,

Then ignore is set to true only if we have a span with IssueEntries that has entry.ignore = true:

if entries.ignore {
issue.ignore = entries.ignore;
}

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:

impl Visit for Issue {
fn record_debug(&mut self, field: &Field, value: &dyn fmt::Debug) {
self.fields.push((field.name(), format!("{value:?}")));
}
fn record_str(&mut self, field: &Field, value: &str) {
if field.name() == "file" {
self.file = value.to_string();
} else {
self.fields.push((field.name(), value.to_string()));
}
}
fn record_u64(&mut self, field: &Field, value: u64) {
if field.name() == "req" {
self.req = value;
}
}
fn record_bool(&mut self, field: &Field, value: bool) {
if field.name() == "ignore" {
self.ignore = value;
}
}

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LeoMcA I have now:

  • Extracted fn populate_issue_from_scope() to make it clearer that the logic only applies to issues in a span scope. (e451c5a)
  • Refined the comments, moving one between the blocks. (c217f6d)

@caugner caugner requested a review from LeoMcA January 19, 2026 10:23
@caugner caugner changed the title chore(doc): ignore errors about missing optional roots fix(doc): handle ignored error events without span (e.g. missing optional roots) Jan 19, 2026
@caugner caugner changed the title fix(doc): handle ignored error events without span (e.g. missing optional roots) fix(doc): handle ignored errors without span (e.g. missing optional roots) Jan 19, 2026
Copy link
Member

@LeoMcA LeoMcA left a comment

Choose a reason for hiding this comment

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

Nice, looks good!

@LeoMcA LeoMcA merged commit 3684232 into main Jan 19, 2026
18 checks passed
@LeoMcA LeoMcA deleted the suppress-optional-root-errors branch January 19, 2026 10:29
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.

2 participants