Skip to content

fix(intelligent-assistant): replace markitdown with unpdf - #5658

Open
Jdubrick wants to merge 2 commits into
redhat-developer:mainfrom
Jdubrick:RHIDP-19100-replace-markitdown
Open

Jdubrick wants to merge 2 commits into
redhat-developer:mainfrom
Jdubrick:RHIDP-19100-replace-markitdown

Conversation

@Jdubrick

@Jdubrick Jdubrick commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Hey, I just made a Pull Request!

✔️ Checklist

  • Replaces markitdown with unpdf
    • This reduces the overall dependency signature of the IA plugin
    • Also removes the dependency on native binaries that are causing the IA plugin to fail on arm64 machines (rhdh local)
  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

…4 errors

Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
@rhdh-gh-app

rhdh-gh-app Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-intelligent-assistant-backend workspaces/intelligent-assistant/plugins/intelligent-assistant-backend patch v5.3.10

Signed-off-by: Jordan Dubrick <jdubrick@redhat.com>
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.01%. Comparing base (d22d1c2) to head (62db7ce).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5658   +/-   ##
=======================================
  Coverage   66.00%   66.01%           
=======================================
  Files        2808     2808           
  Lines      113150   113163   +13     
  Branches    31712    31740   +28     
=======================================
+ Hits        74689    74700   +11     
- Misses      36644    36646    +2     
  Partials     1817     1817           
Flag Coverage Δ *Carryforward flag
adoption-insights 88.86% <ø> (ø) Carriedforward from d22d1c2
ai-integrations 90.89% <ø> (ø) Carriedforward from d22d1c2
app-defaults 77.25% <ø> (ø) Carriedforward from d22d1c2
augment 46.67% <ø> (ø) Carriedforward from d22d1c2
boost 93.94% <ø> (ø) Carriedforward from d22d1c2
bulk-import 73.13% <ø> (ø) Carriedforward from d22d1c2
cost-management 13.56% <ø> (ø) Carriedforward from d22d1c2
dcm 74.35% <ø> (ø) Carriedforward from d22d1c2
e2e-adoption-insights 60.16% <ø> (ø) Carriedforward from d22d1c2
e2e-extensions 62.87% <ø> (ø) Carriedforward from d22d1c2
e2e-global-header 52.43% <ø> (ø) Carriedforward from d22d1c2
e2e-homepage 61.25% <ø> (ø) Carriedforward from d22d1c2
e2e-intelligent-assistant 46.10% <ø> (ø) Carriedforward from d22d1c2
e2e-orchestrator 49.80% <ø> (ø) Carriedforward from d22d1c2
e2e-orchestrator-plugin 49.79% <ø> (ø) Carriedforward from d22d1c2
e2e-quickstart 54.83% <ø> (ø) Carriedforward from d22d1c2
e2e-scorecard 49.88% <ø> (ø) Carriedforward from d22d1c2
e2e-theme 16.43% <ø> (ø) Carriedforward from d22d1c2
extensions 60.42% <ø> (ø) Carriedforward from d22d1c2
global-floating-action-button 71.18% <ø> (ø) Carriedforward from d22d1c2
global-header 69.15% <ø> (ø) Carriedforward from d22d1c2
homepage 86.56% <ø> (ø) Carriedforward from d22d1c2
install-dynamic-plugins 86.58% <ø> (ø) Carriedforward from d22d1c2
intelligent-assistant 79.93% <89.47%> (+<0.01%) ⬆️
konflux 91.98% <ø> (ø) Carriedforward from d22d1c2
lightspeed 69.02% <ø> (ø) Carriedforward from d22d1c2
mcp-integrations 84.46% <ø> (ø) Carriedforward from d22d1c2
orchestrator 77.13% <ø> (ø) Carriedforward from d22d1c2
quickstart 65.83% <ø> (ø) Carriedforward from d22d1c2
sandbox 79.56% <ø> (ø) Carriedforward from d22d1c2
scorecard 92.32% <ø> (ø) Carriedforward from d22d1c2
theme 89.01% <ø> (ø) Carriedforward from d22d1c2
translations 7.91% <ø> (ø) Carriedforward from d22d1c2
x2a 81.73% <ø> (ø) Carriedforward from d22d1c2

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d22d1c2...62db7ce. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@Jdubrick

Copy link
Copy Markdown
Member Author

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 8:33 PM UTC · Completed 8:54 PM UTC

Commit: 62db7ce · View workflow run →

Runtime: claude · Model: claude-opus-4-6 · Effort: high · Cost: $7.20

@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: elevated (3/5)

Details

This dependency-swap PR (markitdown to unpdf) scores elevated primarily due to two dependency files changing with large lockfile churn (yarn.lock: +29/-682), a large blast radius, and an active file history with 11 distinct authors and 15 fix commits in 90 days, offset by clean security and CI signals and a draft/WIP status limiting immediate merge risk.

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Low

  • [naming-coherence] workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts:53 — The exported function is still named convertToMarkdown even though the module was renamed to documentConverter.ts and the JSDoc now says "text for the vector store." For PDFs it returns raw extracted text, not Markdown. See also: [naming conventions] finding at line 88.
    Remediation: Rename the export to convertToText or extractDocumentText to align with the updated file name and JSDoc description.

  • [naming conventions] workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts:88 — Error message still reads "Markdown conversion produced no output" but the function now extracts plain text, making the term inconsistent with the module name and JSDoc. See also: [naming-coherence] finding at line 53.
    Remediation: Change the message to "Text extraction produced no output for ${originalName}".

  • [code organization] workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts:34 — Two private helpers use different declaration styles: normalizeText (line 28) is a const arrow function while extractPdfText (line 34) is an async function declaration. The sibling documentHelpers.ts consistently uses const arrow functions.
    Remediation: Convert extractPdfText to a const arrow function to match the codebase idiom.

  • [documentation comment format] workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts:26 — The JSDoc for normalizeText references the removed dependency markitdown-ts. Future maintainers will have no context for this reference.
    Remediation: Replace "Matches the output previously produced by markitdown-ts." with a forward-looking statement about the normalization purpose.

  • [API shape patterns] workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/notebooksRouter.test.ts:489 — documentConverter.test.ts captures the mock at module scope (const mockExtractText = extractText as jest.Mock) while notebooksRouter.test.ts uses inline (extractText as jest.Mock) casts at each call site.
    Remediation: Add a module-level const mockExtractText = extractText as jest.Mock; in notebooksRouter.test.ts and use it throughout.


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

@fullsend-ai-review fullsend-ai-review 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.

See the review comment for full details.

@Jdubrick
Jdubrick marked this pull request as ready for review November 24, 2026 20:59
@rhdh-qodo-merge

rhdh-qodo-merge Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Fix arm64 notebook uploads by replacing markitdown with unpdf

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Replace markitdown with unpdf to remove the native canvas dependency that breaks arm64 startup.
• Preserve text uploads and reject unreadable or textless PDFs with safe 400 errors.
• Add converter and upload tests, and publish a backend patch changeset.
Merge Risk 🟡 Medium

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The converter, upload endpoint, Files API upload, and vector-store attachment form one bounded document-ingestion integration.
  • The changed text is passed from the upload route into DocumentService rather than implementing an independent technical capability; downstream indexing and retrieval are the consumer outcome of the same notebook-document behavior.
  • PDF validation and conversion occur within the same bounded notebook document upload integration as file creation and vector-store attachment.
  • The rejection path prevents that document from entering the downstream storage path rather than creating an independent capability.
Behavioral complexity 🟡 Medium 🧩 Data transformation, Compatibility cases

  • The changed logic materially changes the conversion conditions.
  • Before: non-plaintext inputs were delegated to markitdown-ts.
  • After: PDF inputs are converted through unpdf with mergePages, txt/md are decoded and normalized locally, and unsupported types remain rejected while JSON/YAML/YML/log continue raw passthrough.
  • Before: one external conversion contract supplied markdown or no output.
  • After: correctness depends on selecting the format branch, matching filename and declared type, interpreting unpdf's extracted text, normalizing line endings and blank-line runs, and rejecting empty output.
  • New correctness conditions are preserving meaningful PDF text across page merging, distinguishing extraction failure from empty text, and preserving the expected text semantics for the newly local txt/md path.
  • The branches are not concurrency or coordinated-state logic; the downstream upload remains an established call sequence.
Potential damage 🟡 Medium 🩹 Incorrect results

  • Conditionally, if extraction or normalization produces incorrect but non-empty text, the uploaded file and subsequent vector-store chunks can represent incorrect document content, causing incorrect notebook search or answers.
  • The source does not establish such a defect; this is the consequence of regression of the changed capability.
  • Reverting code does not repair already uploaded or indexed content.
  • Recoverable by replacing or deleting and re-uploading affected documents after the correct converter is deployed.
  • Recovery requires identifying affected documents and successful vector-store replacement; code rollback alone does not restore previously persisted file contents or chunks.
Assessed commit 62db7ce
Diagram

graph TD
  API["Notebook upload"] --> Converter["Document converter"] --> Type{"File type"}
  Type -->|PDF| PDF["unpdf extraction"] --> Normalize["Normalize text"] --> Service["Document service"]
  Type -->|txt or md| Normalize
  Type -->|json yaml log| Service
Loading
High-Level Assessment

Keep the focused unpdf approach: it removes the native canvas dependency while retaining the existing upload flow. Using PDF.js directly would require more extraction plumbing; retaining markitdown would not address the arm64 failure. Textless PDFs are intentionally rejected rather than adding OCR.

Files changed (7) +227 / -753

Bug fix (2) +41 / -11
documentConverter.tsExtract PDF text with unpdf and handle text locally +40/-10

Extract PDF text with unpdf and handle text locally

• Uses unpdf for PDFs, decodes and normalizes txt/md files, and retains unchanged pass-through behavior for JSON, YAML, and logs. Converts extraction failures and empty results into InputErrors.

workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts

notebooksRouters.tsRoute uploads through the updated document converter +1/-1

Route uploads through the updated document converter

• Changes the notebook upload route's converter import from the markitdown client to the document converter without changing the route's upload flow.

workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/notebooksRouters.ts

Tests (2) +150 / -58
documentConverter.test.tsCover PDF extraction and text-format behavior +110/-58

Cover PDF extraction and text-format behavior

• Replaces markitdown mocks with unpdf mocks. Tests PDF extraction and failures, txt/md normalization, unchanged pass-through formats, empty output, and file-type validation.

workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.test.ts

notebooksRouter.test.tsTest PDF uploads and safe extraction errors +40/-0

Test PDF uploads and safe extraction errors

• Adds router tests for a successful PDF document upload and a 400 response when extraction fails, including a check that the response does not echo uploaded content.

workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/notebooksRouter.test.ts

Other (3) +36 / -684
replace-markitdown-with-unpdf.mdDeclare a backend patch for the PDF extraction change +5/-0

Declare a backend patch for the PDF extraction change

• Adds a patch changeset describing the dependency replacement, architecture compatibility, smaller footprint, and rejection of unreadable or textless PDFs.

workspaces/intelligent-assistant/.changeset/replace-markitdown-with-unpdf.md

package.jsonReplace markitdown-ts with unpdf +2/-2

Replace markitdown-ts with unpdf

• Swaps the backend's document-conversion dependency to unpdf so PDF extraction no longer requires markitdown's native canvas dependency chain.

workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/package.json

yarn.lockPrune markitdown dependencies and lock unpdf +29/-682

Prune markitdown dependencies and lock unpdf

• Locks unpdf 1.9.1 and removes markitdown-ts, PDF parsing packages, native canvas binaries, and other dependencies no longer needed by that chain.

workspaces/intelligent-assistant/yarn.lock

@rhdh-qodo-merge

Copy link
Copy Markdown

Code Review by Qodo


View medium (2)
Remediation recommended
1. Some PDF text is missing from notebooks 🐞 Bug
Description
extractPdfText passes PDF bytes directly to unpdf, but the new dependency does not include
pdfjs-dist, whose assets unpdf uses to configure character maps in Node.js. When an uploaded PDF
contains text whose font requires an external character map, extraction can omit that text or return
no usable text, and the resulting incomplete document is sent to the vector store or rejected.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
PDFs whose fonts require external character maps can lose text because the new extraction path does not supply the character-map assets.

## Fix Focus Areas
- workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts[34-45]
- workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/package.json[54-59]

## Recommended Fix
Provide the PDF.js character-map assets as a packaged dependency and configure a document proxy with a valid local `cMapUrl` before calling `extractText`. Add a regression test using a PDF whose text requires an external character map.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

2. Markdown code loses intentional blank lines 🐞 Bug
Description
normalizeText replaces every run of three or more newline characters with two, including runs
inside fenced code blocks. Uploading a Markdown file with multiple blank lines inside a code sample
changes that sample before DocumentService.uploadFile sends it for indexing; the same
transformation applies to text files.
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new text normalization collapses blank lines inside Markdown code blocks and other whitespace-sensitive uploaded content before indexing.

## Fix Focus Areas
- workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts[24-32]
- workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts[76-92]

## Recommended Fix
Do not collapse blank-line runs in uploaded Markdown and text content. Preserve their original spacing while using a separate trimmed check to reject content that contains only whitespace; add a fenced-code regression test.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


@rhdh-qodo-merge

Copy link
Copy Markdown

Important

The /generate_labels command by Qodo was deprecated on the 1st of October 2026 and is no longer available. We recommend switching to the latest Qodo review capabilities. Learn more

@Jdubrick

Copy link
Copy Markdown
Member Author

Code Review by Qodo

View medium (2)

Remediation recommended 1. Some PDF text is missing from notebooks `🐞 Bug`

Description

extractPdfText passes PDF bytes directly to unpdf, but the new dependency does not include
pdfjs-dist, whose assets unpdf uses to configure character maps in Node.js. When an uploaded PDF
contains text whose font requires an external character map, extraction can omit that text or return
no usable text, and the resulting incomplete document is sent to the vector store or rejected.

Agent prompt

The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
PDFs whose fonts require external character maps can lose text because the new extraction path does not supply the character-map assets.

## Fix Focus Areas
- workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts[34-45]
- workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/package.json[54-59]

## Recommended Fix
Provide the PDF.js character-map assets as a packaged dependency and configure a document proxy with a valid local `cMapUrl` before calling `extractText`. Add a regression test using a PDF whose text requires an external character map.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

  1. Markdown code loses intentional blank lines 🐞 Bug

Description

normalizeText replaces every run of three or more newline characters with two, including runs
inside fenced code blocks. Uploading a Markdown file with multiple blank lines inside a code sample
changes that sample before DocumentService.uploadFile sends it for indexing; the same
transformation applies to text files.

Agent prompt

The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new text normalization collapses blank lines inside Markdown code blocks and other whitespace-sensitive uploaded content before indexing.

## Fix Focus Areas
- workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts[24-32]
- workspaces/intelligent-assistant/plugins/intelligent-assistant-backend/src/service/notebooks/documents/documentConverter.ts[76-92]

## Recommended Fix
Do not collapse blank-line runs in uploaded Markdown and text content. Preserve their original spacing while using a separate trimmed check to reject content that contains only whitespace; add a fenced-code regression test.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Both of these are not new and not introduced by this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant