Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(confluence): index mirrored/included page content via rendered view format#5746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9261c4a
fix(confluence): index mirrored/included page content via rendered vi…
waleedlatif1 0980add
fix(confluence): invalidate existing doc hashes on representation change
waleedlatif1 5789a6a
feat(connectors): full resync re-hydrates rendered content (transclus…
waleedlatif1 fe48d74
refactor(connectors): decouple rehydrate from fullSync deletion seman…
waleedlatif1 60d2b80
refactor(connectors): tidy rehydrate flag + gate Full resync to suppo…
waleedlatif1 6e0595f
fix(connectors): forward rehydrate flag through the Trigger.dev worker
waleedlatif1 92f9f09
fix(connectors): rehydrate forces a full listing so containers aren't…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44 apps/sim/app/api/knowledge/[id]/connectors/[connectorId]/sync/route.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9 apps/sim/app/api/knowledge/[id]/connectors/[connectorId]/sync/route.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 79 additions & 27 deletions
106 ...rkspace/[workspaceId]/knowledge/[id]/components/connectors-section/connectors-section.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -91,6 +91,16 @@ async function fetchLabelsForPages( | ||
| return labelsByPageId | ||
| } | ||
| /** | ||
| * Body representation marker embedded in the contentHash. Bumping this | ||
| * invalidates every previously-synced Confluence document so a one-time | ||
| * re-hydration picks up content newly reachable by the current extraction | ||
| * (e.g. the switch from `storage` to rendered `view`, which expands Include | ||
| * Page / Excerpt macros). Without it, already-indexed pages whose version is | ||
| * unchanged classify as `unchanged` and keep their stale (empty) content. | ||
| */ | ||
| const CONTENT_REPRESENTATION = 'view' | ||
| /** | ||
| * Produces a canonical metadata stub with a deterministic contentHash that | ||
| * does not depend on which API surface (v1 CQL or v2) returned the page. | ||
| @@ -115,7 +125,7 @@ function pageToStub( | ||
| contentDeferred: true, | ||
| mimeType: 'text/plain', | ||
| sourceUrl: options.sourceUrl, | ||
| contentHash: `confluence:${page.id}:${versionKey}`, | ||
| contentHash: `confluence:${CONTENT_REPRESENTATION}:${page.id}:${versionKey}`, | ||
| metadata: { | ||
| spaceId: options.spaceId, | ||
| status: page.status, | ||
| @@ -233,10 +243,18 @@ export const confluenceConnector: ConnectorConfig = { | ||
| if (syncContext) syncContext.cloudId = cloudId | ||
| } | ||
| // Try pages first, fall back to blogposts if not found | ||
| /** | ||
| * Fetch the `view` representation rather than `storage`. Storage format only | ||
| * carries unexpanded macro references (e.g. Include Page / Excerpt Include), | ||
| * so "mirrored" content that pulls in another page's body is stripped to | ||
| * nothing by `htmlToPlainText`. The `view` representation is server-rendered | ||
| * HTML with those macros expanded inline, so included content is indexed too. | ||
| * The v2 single-item GET (`/pages/{id}`, `/blogposts/{id}`) supports | ||
| * `body-format=view`; only the bulk list endpoints are limited to storage/adf. | ||
| */ | ||
| let page: Record<string, unknown> | null = null | ||
| for (const endpoint of ['pages', 'blogposts']) { | ||
| const url = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/${endpoint}/${externalId}?body-format=storage` | ||
| const url = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/${endpoint}/${externalId}?body-format=view` | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| const response = await fetchWithRetry(url, { | ||
| method: 'GET', | ||
| headers: { | ||
| @@ -256,8 +274,8 @@ export const confluenceConnector: ConnectorConfig = { | ||
| if (!page) return null | ||
| const body = page.body as Record<string, unknown> | undefined | ||
| const storage = body?.storage as Record<string, unknown> | undefined | ||
| const rawContent = (storage?.value as string) || '' | ||
| const view = body?.view as Record<string, unknown> | undefined | ||
| const rawContent = (view?.value as string) || '' | ||
| const plainText = htmlToPlainText(rawContent) | ||
| const labelMap = await fetchLabelsForPages(cloudId, accessToken, [String(page.id)]) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.