Skip to content

Fix concatenation bug in "Report a docs issue" URLs#3046

Merged
cotti merged 6 commits intomainfrom
mw-dupe-docs-path
Apr 16, 2026
Merged

Fix concatenation bug in "Report a docs issue" URLs#3046
cotti merged 6 commits intomainfrom
mw-dupe-docs-path

Conversation

@marciw
Copy link
Copy Markdown
Member

@marciw marciw commented Apr 6, 2026

Summary

A recent refactor exposed a bug in how doc URLs are autofilled in the Website issue template. The "What documentation page is affected?" field is being pre-populated with a duplicate /docs segment in the path (for example, elastic.co/docs/docs/reference/ instead of elastic.co/docs/reference/).

Example 1: elastic/docs-content#5788
Example 2: elastic/docs-content#5776

🤖 Claude Code helped me trace this and attempt a fix, described below.
✅ I tested the fix locally with docs-builder serve and it seems to work.

background and more

I'm on triage duty for core-docs and noticed that source:web issues in docs-content have incorrect autofilled URLs for the affected docs page.
Example 1: elastic/docs-content#5788
Example 2: elastic/docs-content#5776

Both of these have duplicate /docs segments in the path.

Seems to be a side effect of ce8705a

Changes

Claude Code's fixes and explanation of what happened:

  • HtmlWriter.cs: removed the redundant UrlPath.JoinUrl(UrlPathPrefix, ...) wrapping from the report link URL construction — current.Url already includes the prefix, matching the pattern used for canonical URLs elsewhere in the codebase.
  • Same fix applied to the breadcrumb structured data (parent.Url), which had the identical issue.

Details

Before (Path.Combine):
Path.Combine("/docs", "/docs/reference/kibana/...")
// → "/docs/reference/kibana/..."  ✓ (accidentally correct)

After (UrlPath.JoinUrl):
UrlPath.JoinUrl("/docs", "/docs/reference/kibana/...")
// → "/docs/docs/reference/kibana/..."  ✗

Path.Combine has a quirk: when the second argument is an absolute path (starts with /), it discards the first argument entirely. So the old code was accidentally correct — it was passing UrlPathPrefix as the left side, but current.Url always starts with /, so Path.Combine silently ignored the prefix and produced the right result.

When the refactor replaced Path.Combine with UrlPath.JoinUrl (which does simple string concatenation), the latent double-prefix bug became visible.

@marciw marciw requested a review from a team as a code owner April 6, 2026 19:52
@marciw marciw requested a review from Mpdreamz April 6, 2026 19:52
@marciw marciw added the bug label Apr 6, 2026
@coderabbitai coderabbitai bot added the fix label Apr 6, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4d85de58-b398-4c2e-b872-91cdf527a71e

📥 Commits

Reviewing files that changed from the base of the PR and between ff1469c and 8b28a55.

📒 Files selected for processing (1)
  • tests/Elastic.Markdown.Tests/DocSet/ReportIssueUrlTests.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Elastic.Markdown.Tests/DocSet/ReportIssueUrlTests.cs

📝 Walkthrough

Walkthrough

RenderLayout now constructs the "report link" Uri using current.Url directly instead of UrlPath.JoinUrl(DocumentationSet.Context.UrlPathPrefix ?? string.Empty, current.Url). CreateStructuredBreadcrumbsData likewise builds breadcrumb item Uris from parent.Url directly (canonical base fallback remains DocumentationSet.Context.CanonicalBaseUrl ?? new Uri("http://localhost")). Added async tests (ReportIssueUrlTests) that set UrlPathPrefix = "docs" and CanonicalBaseUrl = https://www.elastic.co/ to assert report and breadcrumb Uris do not duplicate the prefix (avoid /docs/docs/) and start with the canonical base plus /docs.

Suggested labels

fix

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main bug fix: removing duplicate '/docs' segments from report issue URLs caused by a concatenation logic error.
Description check ✅ Passed The description clearly explains the bug, root cause, and the specific changes made in HtmlWriter.cs to fix URL construction for both report links and breadcrumbs.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch mw-dupe-docs-path

Comment @coderabbitai help to get the list of available commands and usage tips.

@marciw marciw removed the bug label Apr 6, 2026
@cotti
Copy link
Copy Markdown
Contributor

cotti commented Apr 6, 2026

Oh! Good call, thanks for the catch.

Can you put an unit test to guard against regression?

@marciw
Copy link
Copy Markdown
Member Author

marciw commented Apr 9, 2026

Can you put an unit test to guard against regression?

hmm. you probably don't really want me to try! Would it be better to close this and file an issue instead?

@Mpdreamz
Copy link
Copy Markdown
Member

@copilot ammend the PR with a unit test (or two)

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

@copilot ammend the PR with a unit test (or two)

Done — added 3 regression tests in ReportIssueUrlTests (commit a0c6a3d):

  1. NavigationItemUrls_WithUrlPathPrefix_AlreadyIncludeThePrefix — documents that when UrlPathPrefix = "docs", navigation item URLs already start with /docs/, so there's no need to prepend the prefix again.
  2. ReportIssueUrl_WithUrlPathPrefix_DoesNotDuplicatePrefix — verifies the "report a docs issue" URL construction (new Uri(CanonicalBaseUrl, current.Url)) doesn't produce /docs/docs/ in the result.
  3. BreadcrumbUrl_WithUrlPathPrefix_DoesNotDuplicatePrefix — same check for the breadcrumb structured-data URLs.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/Elastic.Markdown.Tests/DocSet/ReportIssueUrlTests.cs`:
- Around line 57-60: In ReportIssueUrlTests.DisposeAsync remove the unnecessary
GC.SuppressFinalize(this) call: the async dispose method DisposeAsync has no
corresponding finalizer, so delete the GC.SuppressFinalize(this) line and leave
the method returning ValueTask.CompletedTask.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d8b2941d-31f6-478c-8dba-ece521a10f23

📥 Commits

Reviewing files that changed from the base of the PR and between e3246a1 and 5838426.

📒 Files selected for processing (1)
  • tests/Elastic.Markdown.Tests/DocSet/ReportIssueUrlTests.cs

Comment thread tests/Elastic.Markdown.Tests/DocSet/ReportIssueUrlTests.cs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@cotti cotti merged commit 2e4940b into main Apr 16, 2026
28 checks passed
@cotti cotti deleted the mw-dupe-docs-path branch April 16, 2026 00:31
@marciw marciw self-assigned this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants