Conversation
Extract documentPathToUrl to shared utility and apply URL transformation in askDocsAgentTool to ensure document paths are converted to valid URLs with leading slashes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughA new utility function Changes
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✏️ Tip: You can disable this entire section by setting Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@doc-agents/src/utils/url.ts`:
- Around line 4-10: documentPathToUrl currently calls docPath.replace and will
throw if docPath is null/undefined or not a string; update the function
signature (documentPathToUrl) to accept a nullable type (e.g., string |
undefined) and add a defensive early-return that checks typeof docPath ===
'string' and docPath.trim() !== '' before proceeding; if the check fails, return
an empty string (or a safe default URL) so the subsequent replace and split
logic (the local variables path, basePath, hash) never run on invalid input.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
doc-agents/src/agent/agent_pulse/tools.tsdoc-agents/src/api/doc-qa/route.tsdoc-agents/src/utils/url.tsdoc-agents/tsconfig.json
🧰 Additional context used
📓 Path-based instructions (1)
doc-agents/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (doc-agents/AGENTS.md)
Use Bun instead of NodeJS as the JavaScript runtime and TypeScript for all source code
Files:
doc-agents/src/utils/url.tsdoc-agents/src/api/doc-qa/route.tsdoc-agents/src/agent/agent_pulse/tools.ts
🧬 Code graph analysis (1)
doc-agents/src/agent/agent_pulse/tools.ts (1)
doc-agents/src/utils/url.ts (1)
documentPathToUrl(4-31)
🔇 Additional comments (3)
doc-agents/tsconfig.json (1)
24-25: Confirm@utils/*alias is honored by build/runtime tooling.TS
pathshelp compile-time resolution only; please verify your Bun/TypeScript build (or bundler) also resolves@utils/*at runtime (e.g., via your usual typecheck/build run).doc-agents/src/api/doc-qa/route.ts (1)
13-18: Nice reuse of the shared URL normalizer.This keeps doc-qa responses consistent with other surfaces.
doc-agents/src/agent/agent_pulse/tools.ts (1)
64-70: Consistent URL normalization in tool responses — LGTM.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Seng Rith <50646727+afterrburn@users.noreply.github.com>
Summary
documentPathToUrlfunction to shared utility (src/utils/url.ts)askDocsAgentToolto fix "Invalid or potentially unsafe URL" errorGet-Started/quickstart.mdx#7-deployare now properly transformed to/Get-Started/quickstart#7-deployTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.