Skip to content

Added attatchment widget for context center articles - #29842

Merged
Rohit0301 merged 16 commits into
mainfrom
article-attachment-widget
Jul 11, 2026
Merged

Rohit0301 merged 16 commits into
mainfrom
article-attachment-widget

Conversation

@Rohit0301

@Rohit0301 Rohit0301 commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Screenshot 2026-07-10 at 11 11 40 AM

Fixes 4915

I worked on ... because ...

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

High-level design:

N/A — small change.

Tests:

Use cases covered

Unit tests

Backend integration tests

Ingestion integration tests

Playwright (UI) tests

Manual testing performed

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Summary by Gitar

  • New feature:
    • Added AttachmentWidget to KnowledgePageDetailRightPanel to display and manage context center article attachments.
    • Implemented UploadFileTab component for the block editor, enabling users to upload files via drag-and-drop.
  • Component updates:
    • Refactored AttachmentWidget to fetch and display attachments by entity FQN using listAssetsByFqn.
    • Added collapsible support to ExtractedMemoriesCard to improve layout flexibility in the sidebar.

This will update automatically on new commits.

Greptile Summary

This PR adds attachment support for context center articles. The main changes are:

  • Adds an attachment widget to the knowledge page right panel.
  • Adds file upload support to the block editor image popover.
  • Adds authenticated attachment download and image loading hooks.
  • Updates article attachment Playwright coverage and locale strings.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/src/components/KnowledgeCenter/AttachmentWidget/AttachmentWidget.tsx Fetches inline assets for the current article and renders loading, empty, list, and download states.
openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/image/UploadFile/UploadFileTab.tsx Adds an upload tab that persists selected files as inline article assets.
openmetadata-ui/src/main/resources/ui/src/components/common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider.tsx Centralizes attachment upload state and keeps upload entry points controlled by the file-upload flag.
openmetadata-ui/src/main/resources/ui/src/hooks/useAuthenticatedImage.ts Loads protected attachment images through the download API with shared request handling and blob URL ownership.
openmetadata-ui/src/main/resources/ui/src/hooks/useAuthenticatedFile.ts Adds protected attachment file downloads with shared in-flight request handling.

Comments Outside Diff (2)

  1. openmetadata-ui/src/main/resources/ui/src/components/common/EntityDescription/EntityAttachmentProvider/EntityAttachmentProvider.tsx, line 99-105 (link)

    P1 security Disabled Upload Falls Through

    When allowFileUpload is false and a non-image file is dropped or pasted, this branch reports the error but then continues into the upload path below. Because onImageUpload is now always wired to the attachment upload implementation, the file can still be persisted after the UI says uploads are not allowed. Return after reporting the error so disabled file-upload contexts cannot reach onImageUpload.

    Context Used: CLAUDE.md (source)

  2. openmetadata-ui/src/main/resources/ui/src/hooks/useAuthenticatedImage.ts, line 2185-2189 (link)

    P1 Shared Blob Revoked Early

    When two image nodes use the same attachment URL, both wait on the same download and receive the same objectUrl. If one node unmounts before the download resolves and its continuation runs first, this branch acquires the URL and immediately releases it because the waiter is stale. That drops the refcount to zero and revokes the URL before the still-mounted node stores it in imageSrc, so the live image can render a broken blob URL.

Reviews (17): Last reviewed commit: "Merge branch 'main' into article-attachm..." | Re-trigger Greptile

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - openmetadata-ui-core-components/CLAUDE.md (source)
  • Context used - AGENTS.md (source)

@Rohit0301 Rohit0301 self-assigned this Jul 8, 2026
@Rohit0301
Rohit0301 requested a review from a team as a code owner July 8, 2026 11:55
@Rohit0301 Rohit0301 added the safe to test Add this label to run secure Github workflows on PRs label Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 64%
64.08% (74485/116221) 47.61% (43821/92035) 48.63% (13377/27507)

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (28 flaky)

✅ 4461 passed · ❌ 0 failed · 🟡 28 flaky · ⏭️ 127 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 425 0 2 16
✅ Shard 2 11 0 0 0
🟡 Shard 3 783 0 10 40
🟡 Shard 4 815 0 1 18
🟡 Shard 5 821 0 5 5
🟡 Shard 6 826 0 1 46
🟡 Shard 7 780 0 9 2
🟡 28 flaky test(s) (passed on retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab IS visible for supported type: metric (shard 1, 1 retry)
  • Flow/SearchRBAC.spec.ts › the browse tree only shows the asset-type categories a user can access (shard 1, 1 retry)
  • Features/BulkEditEntity.spec.ts › Table (shard 3, 1 retry)
  • Features/BulkImportWithDotInName.spec.ts › CSV with quoted FQN loads correctly in import grid (shard 3, 1 retry)
  • Features/BulkImportWithDotInName.spec.ts › Full import cycle with dot in service name (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Article listing search filters, clears, and shows empty state (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › Article list cards, recently viewed widget, and pagination work (shard 3, 1 retry)
  • Features/ContextCenterArticles.spec.ts › description: switching articles does not bleed unsaved content into next article (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › closing the modal removes ?memory= param from the URL (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › adding a linked asset in edit mode shows entity badge on the row (shard 3, 1 retry)
  • Features/ContextCenterMemories.spec.ts › typing the linked table name in the asset search returns it as a result (shard 3, 1 retry)
  • Features/Glossary/GlossaryHierarchy.spec.ts › should cancel move operation (shard 3, 1 retry)
  • Features/SearchExport.spec.ts › Search mode visible export downloads CSV with tab-specific row count (shard 4, 1 retry)
  • Features/UserProfileOnlineStatus.spec.ts › Should show online status badge on user profile for active users (shard 5, 1 retry)
  • Flow/PersonaFlow.spec.ts › Set default persona for team should work properly (shard 5, 1 retry)
  • Pages/CustomProperties.spec.ts › Integer (shard 5, 1 retry)
  • Pages/CustomProperties.spec.ts › Set table-cp custom property on column and verify in UI (shard 5, 2 retries)
  • Pages/CustomProperties.spec.ts › Set enum custom property on column and verify in UI (shard 5, 2 retries)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 6, 1 retry)
  • Pages/ExplorePageRightPanel.spec.ts › Should NOT show restricted edit buttons for Data Steward for dashboardDataModel (shard 7, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Glossary Bulk Import Export (shard 7, 1 retry)
  • Pages/GlossaryImportExport.spec.ts › Import partial success - some terms pass, some fail (shard 7, 1 retry)
  • Pages/InputOutputPorts.spec.ts › Output ports section collapse/expand (shard 7, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify Impact Analysis service filter selection (shard 7, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for pipelineService in platform lineage (shard 7, 1 retry)
  • Pages/Lineage/LineageRightPanel.spec.ts › Verify custom properties tab is NOT visible for apiService in platform lineage (shard 7, 1 retry)
  • Pages/TasksUIFlow.spec.ts › Create and reject tag task for Dashboard via UI (shard 7, 1 retry)
  • Pages/TestSuite.spec.ts › Logical TestSuite (shard 7, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@sonarqubecloud

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 11 resolved / 11 findings

Integrates an attachment widget for context center articles, enabling file uploads and management within the Knowledge Center. This release addresses all previous findings related to file upload security, blob URL lifecycle, and UI feedback mechanisms.

✅ 11 resolved
✅ Bug: Possible crash when asset.extension is undefined

📄 openmetadata-ui/src/main/resources/ui/src/components/KnowledgeCenter/AttachmentWidget/AttachmentWidget.tsx:54
In fetchAttachments, attachments are mapped with fileType: asset.extension.replace(".", "") || ''. The Asset.extension field is optional (string | undefined per generated/attachments/asset.ts). If any returned asset has no extension, asset.extension.replace(...) throws a TypeError: Cannot read properties of undefined (reading 'replace'), which is caught by the surrounding try/catch and silently clears the entire attachment list (setAttachments([])). This means one asset with a missing extension hides all attachments. Guard against undefined before calling .replace.

✅ Bug: Upload indicator toggled after upload completes, never shows

📄 openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/image/UploadFile/UploadFileTab.tsx:42-56
In customRequest, onUploadingChange(true) is called only after await uploadAsset(...) has already resolved, and onUploadingChange(false) is called immediately after. As a result the uploading state flips true→false in the same synchronous tick after the network request finishes, so the uploading indicator is effectively never shown while the upload is in progress. onUploadingChange(true) should be set before awaiting the upload, and the reset to false should happen in a finally block (also covering the error path, which currently leaves the flag unchanged).

✅ Bug: Empty entityFqn passes undefined guard and uploads with empty link

📄 openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/image/UploadFile/UploadFileTab.tsx:21 📄 openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/image/UploadFile/UploadFileTab.tsx:35
entityFqn is destructured with a default of '' (entityFqn = ''), then the guard checks isUndefined(entityFqn). Because of the default, entityFqn is never undefined, so this branch is dead code and an upload attempted before the entity has an FQN proceeds with an empty string, producing an invalid entity link instead of showing the intended message.image-upload-after-asset-creation message. Check for empty/falsy value instead of only undefined.

✅ Quality: showErrorToast receives raw Error cast to string

📄 openmetadata-ui/src/main/resources/ui/src/components/KnowledgeCenter/AttachmentWidget/AttachmentWidget.tsx:92-94
In handleDownload, errors are passed via showErrorToast(error as string). The thrown values here are Error objects (e.g. new Error('Failed to fetch file')) or Axios errors, not strings. showErrorToast accepts AxiosError | string | JSX.Element; passing an Error cast as string bypasses type safety and does not reliably render the error message. Pass the error directly (as AxiosError) or provide a proper string/fallback message.

✅ Quality: Hardcoded 'Upload' tab label not internationalized

📄 openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/Extensions/image/ImageClassBase.ts:37
The new upload tab is added with label: 'Upload', a hardcoded English string. Per the project's i18n requirements, user-visible strings must use translations. Use i18n.t('label.upload') (i18n is already imported in this file) to keep the label localized, consistent with other UI strings.

...and 6 more resolved from earlier reviews

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

This branch was previously deployed

1 inactive deployment
test — 1b3f904d Deployed Jul 10, 2026 by Rohit0301 via playwright-ci-postgresql (2, 7) #55907
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants