Skip to content

Derive connector docs URLs from the sitemap instead of a hardcoded Area-to-category map - #48

Merged
daneshk merged 2 commits into
mainfrom
fix/connector-docs-url-sitemap-lookup
Jul 24, 2026
Merged

Derive connector docs URLs from the sitemap instead of a hardcoded Area-to-category map#48
daneshk merged 2 commits into
mainfrom
fix/connector-docs-url-sitemap-lookup

Conversation

@daneshk

@daneshk daneshk commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace the guessed docs URL (Area/ keyword -> fixed category slug -> assumed page slug) with a URL read directly from the docs sitemap, since page slugs aren't consistent across connectors.
  • getConnectorDocsUrlMap() (renamed from getDocumentedConnectors()) now parses the sitemap into a full package name -> docs URL map, picking the "overview" page when a package has multiple docs pages.
  • CONNECTOR_DOCS and getConnectorDocsUrl() are kept only as a manual override for the rare cases the sitemap can't resolve.
  • ConnectorDetailPage checks the manual override first, then falls back to the sitemap-derived map.

Test plan

  • npm run typecheck passes
  • Manually verify the "Documentation" button appears/links correctly on a few connector detail pages (including one relying on the sitemap-derived path, not the hardcoded map)

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Summary

  • Resolve connector documentation URLs directly from the documentation sitemap, selecting the overview page when multiple pages exist.
  • Add getConnectorDocsUrlMap() with six-hour caching and resilient loading behavior.
  • Retain manual URL overrides for connectors not resolved through the sitemap.
  • Update ConnectorDetailPage to prefer overrides and otherwise use sitemap-derived URLs.
  • Version the sitemap cache format and improve concurrent loading fallback behavior.
  • Type checking passes; documentation links were manually verified on several connector pages.

Walkthrough

Connector documentation resolution now uses hardcoded package mappings or canonical overview URLs derived from the documentation sitemap. The sitemap-derived map is cached in localStorage for six hours and retries after failures. The connector details page prefetches this map and resolves documentation links through the hardcoded lookup first, followed by the sitemap map.

Sequence Diagram(s)

sequenceDiagram
  participant ConnectorDetailPage
  participant ConnectorUtils
  participant DocsSitemap
  participant localStorage
  ConnectorDetailPage->>ConnectorUtils: request documentation URL map
  ConnectorUtils->>localStorage: read cached map
  ConnectorUtils->>DocsSitemap: fetch sitemap on cache miss
  DocsSitemap-->>ConnectorUtils: sitemap URLs
  ConnectorUtils->>localStorage: cache canonical overview URLs
  ConnectorUtils-->>ConnectorDetailPage: package-to-URL map
  ConnectorDetailPage->>ConnectorUtils: resolve package override
  ConnectorUtils-->>ConnectorDetailPage: documentation URL or undefined
Loading

Suggested reviewers: aashikam

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description cannot be fully validated because pre-merge checks currently support only a single pull request description template. Please use the supported single PR description template so this check can be evaluated reliably.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: resolving connector docs URLs from the sitemap instead of the Area-to-category map.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/connector-docs-url-sitemap-lookup

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/connector-utils/connector-utils.ts`:
- Around line 557-558: Version the SITEMAP_CACHE_KEY used by the sitemap cache
so pre-deploy Set-shaped entries cannot be read as the new {entries, timestamp}
format. Update the cache read logic around the sitemap caching flow to trust
parsed data only when entries is an array, otherwise treat it as a cache miss
and rebuild the cache.
- Around line 592-601: Update getConnectorDocsUrlMap so sitemapPromise stores
and returns the promise with the empty-map rejection fallback applied, rather
than retaining the raw async IIFE promise. Ensure concurrent callers hitting the
existing sitemapPromise guard receive the same resolved empty Map when fetch or
parsing fails, including the corresponding handling near the later
sitemapPromise assignment.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8153a57d-b8e1-4cc4-aa29-15fe0350e2d4

📥 Commits

Reviewing files that changed from the base of the PR and between 30cf443 and c6dbf53.

📒 Files selected for processing (3)
  • src/lib/connector-utils/connector-utils.ts
  • src/lib/connector-utils/index.ts
  • src/pages/ConnectorDetailPage.tsx

Comment on lines 557 to 558
const SITEMAP_CACHE_KEY = 'connector_docs_sitemap';
const SITEMAP_CACHE_TTL = 6 * 60 * 60 * 1000; // 6 hours

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Cache key reuse across schema change risks stale-format reads.

SITEMAP_CACHE_KEY is unchanged from the prior Set-based caching scheme, but the stored shape moved to {entries, timestamp}. If a client's browser already holds a pre-deploy cache entry under this key, entries would be undefined after parsing, and new Map(undefined) silently yields an empty map that is then treated as a fresh, valid cache for the remaining TTL window — degrading documentation links to the fallback state for up to 6 hours post-deploy.

Consider bumping the cache key (e.g. append a version suffix) or validating Array.isArray(entries) before trusting the cached value.

Also applies to: 597-602

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/connector-utils/connector-utils.ts` around lines 557 - 558, Version
the SITEMAP_CACHE_KEY used by the sitemap cache so pre-deploy Set-shaped entries
cannot be read as the new {entries, timestamp} format. Update the cache read
logic around the sitemap caching flow to trust parsed data only when entries is
an array, otherwise treat it as a cache miss and rebuild the cache.

Comment thread src/lib/connector-utils/connector-utils.ts
@daneshk

daneshk commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both CodeRabbit findings in f1592ef:

  • Versioned SITEMAP_CACHE_KEY (connector_docs_sitemap_v2) so a pre-deploy {packageNames}-shaped cache entry can't be misread as the new {entries} shape.
  • getConnectorDocsUrlMap() now reassigns sitemapPromise to the wrapped/catch-handled promise, so concurrent callers hitting the dedup guard get the documented empty-map fallback on failure instead of a raw rejection.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/connector-utils/connector-utils.ts (1)

623-633: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Check the sitemap response before caching its contents.

A non-success sitemap response still reaches response.text() and can generate an empty/partial map that is persisted for the 6-hour TTL. Check response.ok before parsing and throw so the outer fallback returns an empty map without caching bad data.

🔧 Proposed fix
 const response = await fetch(DOCS_SITEMAP_URL);
+if (!response.ok) {
+  throw new Error(`Failed to fetch connector sitemap: ${response.status}`);
+}
 const xml = await response.text();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/connector-utils/connector-utils.ts` around lines 623 - 633, Update
the sitemap-fetching flow before response.text() to validate response.ok and
throw on non-success responses. Ensure the existing outer fallback handles the
error by returning an empty map, preventing the docsUrlMap from being persisted
to localStorage when the response is invalid.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/lib/connector-utils/connector-utils.ts`:
- Around line 623-633: Update the sitemap-fetching flow before response.text()
to validate response.ok and throw on non-success responses. Ensure the existing
outer fallback handles the error by returning an empty map, preventing the
docsUrlMap from being persisted to localStorage when the response is invalid.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fd3629d5-a775-4d2d-b7c9-966db0c9da72

📥 Commits

Reviewing files that changed from the base of the PR and between c6dbf53 and f1592ef.

📒 Files selected for processing (1)
  • src/lib/connector-utils/connector-utils.ts

@RDPerera RDPerera left a comment

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.

LGTM

@daneshk
daneshk merged commit 2bba324 into main Jul 24, 2026
8 checks passed
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