Skip to content

Warn on invalid markdown snippet markers - #1576

Open
ahfoysal wants to merge 3 commits into
open-telemetry:mainfrom
ahfoysal:warn-invalid-markdown-snippets
Open

Warn on invalid markdown snippet markers#1576
ahfoysal wants to merge 3 commits into
open-telemetry:mainfrom
ahfoysal:warn-invalid-markdown-snippets

Conversation

@ahfoysal

@ahfoysal ahfoysal commented Jul 7, 2026

Copy link
Copy Markdown

Refs #501

This warns when registry update-markdown sees an HTML comment that looks like a semconv/weaver snippet marker but does not parse as one.

Marker validation now runs during the generator's existing line-by-line Markdown update pass and returns warnings as non-fatal WResult diagnostics, avoiding a second file read and parse. Existing whitespace-tolerant marker parsing remains unchanged.

Tests:

  • cargo fmt --all --check
  • cargo test -p weaver_semconv_gen recognizes_invalid_snippet_markers
  • cargo test -p weaver test_registry_update_markdown_warns_on_invalid_snippet_marker
  • cargo clippy -p weaver_semconv_gen --all-targets --no-deps

@ahfoysal
ahfoysal requested a review from a team as a code owner July 7, 2026 06:17
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 7, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

Comment thread src/registry/update_markdown.rs Outdated
let path = entry.path().display().to_string();
if let Ok(contents) = fs::read_to_string(entry.path()) {
for marker in invalid_snippet_markers(&contents) {
marker_warnings.extend_from_vec(vec![DiagnosticMessage::new(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should be able to create DiagnosticMessages directly from invalid_snippet_markers method and then rename it to something like validate_markers (that returns marker_warnings array)

Comment thread crates/weaver_semconv_gen/src/parser.rs Outdated

/// Returns true if the line is an HTML comment that looks like a snippet marker,
/// but does not parse as a supported marker.
pub fn is_invalid_snippet_marker(line: &str) -> bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just from readability perspective, is_invalid is harder to read / understand

Suggested change
pub fn is_invalid_snippet_marker(line: &str) -> bool {
pub fn is_valid_snippet_marker(line: &str) -> bool {

Comment thread crates/weaver_semconv_gen/src/lib.rs Fixed
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 10, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-08-07 15:42 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.51282% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.0%. Comparing base (6fb9009) to head (d70195b).
⚠️ Report is 33 commits behind head on main.

Files with missing lines Patch % Lines
crates/weaver_semconv_gen/src/lib.rs 65.0% 22 Missing ⚠️
crates/weaver_semconv_gen/src/parser.rs 93.3% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1576     +/-   ##
=======================================
- Coverage   82.3%   81.0%   -1.3%     
=======================================
  Files        129     130      +1     
  Lines      10971   11509    +538     
=======================================
+ Hits        9032    9333    +301     
- Misses      1939    2176    +237     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ahfoysal

Copy link
Copy Markdown
Author

Addressed the review comments: marker validation now returns diagnostics directly, the parser helper uses positive marker validation, and the bool::then path is gone.

Comment thread crates/weaver_semconv_gen/src/parser.rs
Comment thread src/registry/update_markdown.rs Outdated
Comment thread crates/weaver_semconv_gen/src/lib.rs
/// contents: The contents of the markdown.
/// attribute_registry_base_url: Legacy mechanism to pass parameters to the snippet templates.
/// Returns: the updated markdown or an error.
fn update_markdown_contents(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It MAY be tedious - and you can add a TODO for this if so -

But we can just remove this method or update its signature to take WResult directly. I'd rather do that than have two methods here which do the same thing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you remove this method now?

It looks like it's just a passthrough in all cases.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 30, 2026

Copy link
Copy Markdown

Hi @ahfoysal — just a friendly reminder that this pull request is waiting on you.

There are still items that need your attention. See the dashboard status comment for the full list. You don't need to push a code change to hand it back — replying to move each discussion forward is enough, whether that's answering a question, explaining why no change is needed, or asking a follow-up. The dashboard then automatically routes it back to reviewers.

If you believe this pull request is incorrectly routed as waiting on the author, comment /dashboard route:reviewers to route it from waiting on the author to waiting on reviewers.

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.

4 participants