Knowledge segments: DOCX/PDF image URLs should be deployment-agnostic #22259

Open
opened 2026-02-21 20:16:20 -05:00 by yindo · 1 comment
Owner

Originally created by @BeautyyuYanli on GitHub (Feb 20, 2026).

Summary

Extracted image links in knowledge segment content can embed absolute hosts, which may not be browser-reachable in some deployments and can break rendering.

Problem

  • DOCX/PDF extractors can emit absolute .../files/<id>/file-preview links.
  • Segment signing logic should normalize both absolute and relative file-preview/image-preview URLs.

Expected

Knowledge segment image links should be host-agnostic and reliably signable across deployment topologies.

Proposed

  • Emit relative links (/files/<id>/file-preview) from extractors.
  • Extend signing rewrite patterns to handle absolute URLs as well.
Originally created by @BeautyyuYanli on GitHub (Feb 20, 2026). ## Summary Extracted image links in knowledge segment content can embed absolute hosts, which may not be browser-reachable in some deployments and can break rendering. ## Problem - DOCX/PDF extractors can emit absolute `.../files/<id>/file-preview` links. - Segment signing logic should normalize both absolute and relative `file-preview`/`image-preview` URLs. ## Expected Knowledge segment image links should be host-agnostic and reliably signable across deployment topologies. ## Proposed - Emit relative links (`/files/<id>/file-preview`) from extractors. - Extend signing rewrite patterns to handle absolute URLs as well.
yindo added the 💪 enhancement label 2026-02-21 20:16:20 -05:00
Author
Owner

@darshjme-codes commented on GitHub (Feb 20, 2026):

Extracted image URLs in knowledge segments sometimes use absolute host paths like https://example.com/files/123/file-preview, which can be unreachable in some deployments and break rendering.

Fix:

  • Emit relative links (/files/<id>/file-preview) from the DOCX/PDF extractors.
  • Update the signing rewrite step to normalize both absolute and relative URLs.
// normalize preview URLs before signing
function normalizePreviewUrl(url) {
  // turn any absolute http(s):// preview into a relative path
  return url.replace(/^https?:\/\/(.*?)\//, '/') + url.split('/').slice(-1).join('/');
}

// example usage in segment signing
segment.links = segment.links.map(normalizePreviewUrl);

This ensures the URLs are host‑agnostic and can be signed consistently regardless of the deployment topology.

Fixes #452 – signed URLs now work on any host.

@darshjme-codes commented on GitHub (Feb 20, 2026): Extracted image URLs in knowledge segments sometimes use absolute host paths like `https://example.com/files/123/file-preview`, which can be unreachable in some deployments and break rendering. **Fix:** - Emit relative links (`/files/<id>/file-preview`) from the DOCX/PDF extractors. - Update the signing rewrite step to normalize both absolute and relative URLs. ```js // normalize preview URLs before signing function normalizePreviewUrl(url) { // turn any absolute http(s):// preview into a relative path return url.replace(/^https?:\/\/(.*?)\//, '/') + url.split('/').slice(-1).join('/'); } // example usage in segment signing segment.links = segment.links.map(normalizePreviewUrl); ``` This ensures the URLs are host‑agnostic and can be signed consistently regardless of the deployment topology. Fixes #452 – signed URLs now work on any host.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#22259