Fix concatenation bug in "Report a docs issue" URLs#3046
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRenderLayout now constructs the "report link" Uri using Suggested labelsfix 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Comment |
|
Oh! Good call, thanks for the catch. 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? |
|
@copilot ammend the PR with a unit test (or two) |
…fix duplication Agent-Logs-Url: https://github.com/elastic/docs-builder/sessions/e2174a2c-285c-407b-984e-41a8e2d61217 Co-authored-by: Mpdreamz <245275+Mpdreamz@users.noreply.github.com>
Done — added 3 regression tests in
|
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
tests/Elastic.Markdown.Tests/DocSet/ReportIssueUrlTests.cs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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
/docssegment in the path (for example,elastic.co/docs/docs/reference/instead ofelastic.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 serveand it seems to work.background and more
I'm on triage duty for core-docs and noticed that
source:webissues indocs-contenthave 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
/docssegments 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 redundantUrlPath.JoinUrl(UrlPathPrefix, ...)wrapping from the report link URL construction —current.Urlalready includes the prefix, matching the pattern used for canonical URLs elsewhere in the codebase.(parent.Url), which had the identical issue.Details
Path.Combinehas 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 passingUrlPathPrefixas the left side, butcurrent.Urlalways starts with/, soPath.Combinesilently ignored the prefix and produced the right result.When the refactor replaced
Path.CombinewithUrlPath.JoinUrl(which does simple string concatenation), the latent double-prefix bug became visible.