Skip to content

fix(ui): render icon/image URLs by real load outcome instead of regex pre-validation - #31982

Merged
Rohit0301 merged 6 commits into
mainfrom
fix-29895
Aug 25, 2026
Merged

Rohit0301 merged 6 commits into
mainfrom
fix-29895

Conversation

@Rohit0301

@Rohit0301 Rohit0301 commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Summary

  • Adds an Icon component (components/common/Icon/Icon.tsx) that renders known icon names
    synchronously, and for image URLs shows a loading skeleton then swaps to the real <img> or a
    caller-supplied fallback based on the actual browser onLoad/onError outcome — instead of only
    pre-validating the URL string against a regex (isImageUrl) and always rendering an <img> even
    when it 404s.
  • Removes renderIcon (the old stateless, regex-only helper) entirely and migrates every call site
    to <Icon>: ClassificationUtils, DomainUtils, DataProductUtils, TagChip, CertificationTag
    (also collapses a duplicate manual <img> fallback that's now dead code), TagsV1, Certification,
    and TagPage.
  • Icon lives at components/common/Icon/Icon.tsx per the shared-icon-wrapper location already
    named in DEVELOPER_HANDBOOK.md. utils/IconUtils.tsx keeps only the pure, non-component
    utilities (isImageUrl, getTagImageSrc, ICON_MAP, getEntityAvatarProps, etc.).

Fixes 29895

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:

Screenshot 2026-08-24 at 10 57 45 PM Screenshot 2026-08-24 at 10 57 55 PM Screenshot 2026-08-24 at 10 58 04 PM Screenshot 2026-08-24 at 10 58 13 PM Screenshot 2026-08-24 at 10 58 21 PM

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.

Greptile Summary

The PR introduces a shared stateful icon renderer that selects known icons synchronously and handles image URLs according to browser load outcomes.

  • Migrates tag, certification, domain, classification, and data-product icon rendering to the shared component.
  • Adds image loading, success, error, fallback, and styling tests.
  • Removes the former stateless renderIcon helper while retaining pure icon utilities.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.tsx Adds the shared icon/image lifecycle component and resolves the previously reported URL-change error latch and loading-layout issue.
openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.test.tsx Covers named icons, invalid values, image loading transitions, fallbacks, and styling behavior.
openmetadata-ui/src/main/resources/ui/src/components/common/CertificationTag/CertificationTag.tsx Replaces duplicated custom-image handling with the shared Icon component and a certification fallback.
openmetadata-ui/src/main/resources/ui/src/components/Tag/TagsV1/TagsV1.component.tsx Migrates tag icon rendering to Icon while retaining the existing default tag glyph.
openmetadata-ui/src/main/resources/ui/src/components/common/atoms/TagChip/TagChip.tsx Migrates chip icons to Icon with a default Tag01 fallback.

Reviews (5): Last reviewed commit: "lint fix" | Re-trigger Greptile

@Rohit0301 Rohit0301 self-assigned this Aug 24, 2026
@Rohit0301 Rohit0301 added the safe to test Add this label to run secure Github workflows on PRs label Aug 24, 2026
@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added the UI UI specific issues label Aug 24, 2026
@Rohit0301 Rohit0301 added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Aug 24, 2026
@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 29 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 29 warning(s) across 8 changed file(s).

Count Rule
11 openmetadata-imports/no-circular-imports
6 react-hooks/exhaustive-deps
3 sonarjs/cyclomatic-complexity
3 openmetadata-imports/no-lower-layer-page-imports
2 sonarjs/no-nested-conditional
2 sonarjs/no-duplicate-string
1 openmetadata-imports/no-internal-barrel-imports
1 sonarjs/cognitive-complexity
All findings
Location Rule Message
🟡 src/components/Certification/Certification.component.tsx:119:9 react-hooks/exhaustive-deps The 'handleScroll' function makes the dependencies of useMemo Hook (at line 213) change on every render. Move it inside the useMemo callback. Alternatively, wra
🟡 src/components/Certification/Certification.component.tsx:183:21 sonarjs/no-nested-conditional Extract this nested ternary operation into an independent statement.
🟡 src/components/Certification/Certification.component.tsx:249:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'currentCertificate' and 'getCertificationData'. Either include them or remove the dependency array. If 'setSelec
🟡 src/components/Tag/TagsV1/TagsV1.component.tsx:34:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/components/Tag/TagsV1/TagsV1.component.tsx:35:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/components/Tag/TagsV1/TagsV1.component.tsx:36:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/components/common/CertificationTag/CertificationTag.tsx:21:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/components/common/atoms/TagChip/TagChip.tsx:88:4 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 11 which is greater than 10 authorized.","cost":1,"secondaryLocations":[{"line":88,"column":3,"endLine":88,"endColumn":
🟡 src/pages/TagPage/TagPage.tsx:72:1 openmetadata-imports/no-internal-barrel-imports Import the internal module directly instead of its index barrel so unrelated siblings do not enter the bundle graph.
🟡 src/pages/TagPage/TagPage.tsx:138:20 sonarjs/cognitive-complexity Refactor this function to reduce its Cognitive Complexity from 24 to the 15 allowed.
🟡 src/pages/TagPage/TagPage.tsx:138:20 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 25 which is greater than 10 authorized.","cost":15,"secondaryLocations":[{"line":138,"column":19,"endLine":138,"endColu
🟡 src/pages/TagPage/TagPage.tsx:277:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 'tagItem'. Either include it or remove the dependency array.
🟡 src/pages/TagPage/TagPage.tsx:302:9 sonarjs/no-nested-conditional Extract this nested ternary operation into an independent statement.
🟡 src/pages/TagPage/TagPage.tsx:326:9 react-hooks/exhaustive-deps The 'activeTabHandler' function makes the dependencies of useCallback Hook (at line 496) change on every render. To fix this, wrap the definition of 'activeTabH
🟡 src/pages/TagPage/TagPage.tsx:407:21 sonarjs/no-duplicate-string Define a constant instead of duplicating this literal 5 times.
🟡 src/pages/TagPage/TagPage.tsx:457:21 sonarjs/no-duplicate-string Define a constant instead of duplicating this literal 3 times.
🟡 src/pages/TagPage/TagPage.tsx:723:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 'fetchFeedCount'. Either include it or remove the dependency array.
🟡 src/pages/TagPage/TagPage.tsx:800:6 react-hooks/exhaustive-deps React Hook useMemo has a missing dependency: 't'. Either include it or remove the dependency array.
🟡 src/utils/ClassificationUtils.tsx:29:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/utils/DataProductUtils.tsx:32:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/utils/DataProductUtils.tsx:33:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/utils/DataProductUtils.tsx:34:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/utils/DataProductUtils.tsx:35:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/utils/DataProductUtils.tsx:47:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/utils/DataProductUtils.tsx:186:35 sonarjs/cyclomatic-complexity {"message":"Function has a complexity of 19 which is greater than 10 authorized.","cost":9,"secondaryLocations":[{"line":186,"column":34,"endLine":186,"endColum
🟡 src/utils/DomainUtils.tsx:29:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/utils/DomainUtils.tsx:30:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.
🟡 src/utils/DomainUtils.tsx:40:1 openmetadata-imports/no-lower-layer-page-imports Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here.
🟡 src/utils/DomainUtils.tsx:41:1 openmetadata-imports/no-circular-imports This runtime import participates in a circular dependency. Extract the shared type/constant/utility or invert the dependency.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 67%
67.07% (80438/119914) 51.46% (49253/95702) 52.44% (14712/28050)

@gitar-bot

gitar-bot Bot commented Aug 25, 2026

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

Adds a shared Icon component that handles named icons and asynchronous image loading with fallbacks, and successfully migrates existing icon rendering across UI components. Addresses the icon loadState reset finding.

✅ 1 resolved
✅ Bug: Icon loadState not reset when iconValue prop changes

📄 openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.tsx:48 📄 openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.tsx:65 📄 openmetadata-ui/src/main/resources/ui/src/components/common/Icon/Icon.tsx:91-92
The internal loadState is initialized only on mount and never reset when iconValue changes. When React reuses an Icon instance by position across changing data (Ant Design table rows in ClassificationUtils, tag lists in TagsV1/TagChip), a previously-errored icon keeps loadState==='error' and immediately renders the fallback for a new, valid URL; a previously-loaded icon skips the skeleton and briefly shows the old image. Reset the state when iconValue changes, e.g. add useEffect(() => setLoadState('loading'), [iconValue]), or key the <img>/component by iconValue.

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 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 303eb99bc546efb0e230804af9c6ca3ac372b0db in Playwright run 32813606827, attempt 1.

✅ 605 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking targets: ✅ met · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 55m 14s

⏱️ Max setup 5m 46s · max shard execution 19m 14s · max shard-job elapsed before upload 22m 16s · reporting 4s

🌐 218.69 requests/attempt · 2.87 app boots/UI scenario · 5.89% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 218.69 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.87 per UI scenario (1829 boots / 638 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 153 0 0 0 0 0
✅ Shard chromium-02 163 0 0 0 0 0
✅ Shard chromium-03 135 0 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

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

@Rohit0301
Rohit0301 enabled auto-merge August 25, 2026 07:26
@Rohit0301
Rohit0301 added this pull request to the merge queue Aug 25, 2026
Merged via the queue into main with commit 3dfb326 Aug 25, 2026
96 checks passed
@Rohit0301
Rohit0301 deleted the fix-29895 branch August 25, 2026 10:34
Rohit0301 added a commit that referenced this pull request Aug 26, 2026
…#32066)

* fix(ui): port renderIcon → <Icon> component to 1.13 (PR #31982)

Adds the new Icon component (components/common/Icon/Icon.tsx) that renders
icon names synchronously and image URLs with a loading skeleton + real
onLoad/onError fallback, replacing the stateless renderIcon regex-only helper.

Migrates all 1.13 call sites:
- Certification.component, TagsV1, CertificationTag (preserves 1.13 size variants)
- TagPage, ClassificationUtils, DataProductUtils, DomainUtils
- MUIIconPicker (1.13-only call site not in main PR)

Removes renderIcon from IconUtils.tsx and its tests from IconUtils.test.tsx.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(ui): resolve cached-image icons staying hidden after table re-render

When a new tag is added the table unmounts and remounts <Icon> components.
On remount loadState resets to 'loading' and the img is hidden. For already-
cached images the browser fires the DOM load event synchronously while
creating the <img> element — before React attaches its onLoad listener — so
the event is silently dropped and the image stays hidden forever.

Fix: add imgRef to the <img> and a second useEffect[loadState] that checks
img.complete immediately after every 'loading' transition. If the browser
already holds the image, complete is true right after mount and we resolve
the state without waiting for the missed event.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(ui): give Icon span a fixed size and move className to the img

The <span> wrapper had no width/height of its own, causing two issues:
- Layout shift between loading (Skeleton) and loaded (img) states because
  the span is display:inline and collapses to its child's size.
- className passed by callers (e.g. certification-img) landed on the <span>
  rather than the <img>, breaking CSS selectors like img.certification-img.

Fix:
- Set display:inline-flex + width/height:size + flexShrink:0 on the span so
  the layout box is stable regardless of which child is visible.
- Move className from <span> to <img> so element-type CSS selectors work.
- Remove the now-redundant flexShrink:0 from TagsV1's wrapperStyle (the
  span provides it by default).

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(ui): fix empty certification-icon div when iconURL is unknown

JSX elements are always truthy objects, so `renderedIcon ?` was always
true whenever iconURL was set — even when <Icon> produced no visible
output. For certifications whose iconURL is neither in ICON_MAP nor a
valid image URL, <Icon> returned an empty fragment but the truthy check
still wrapped it in <div className="certification-icon">, leaving an
empty div.

Fix: remove the isIcon / renderedIcon variables and the 3-way conditional
entirely. Replace with a direct <Icon fallback={<CertificationIcon/>}> call
always inside .certification-icon, so every case (named icon, image URL,
unknown value, no iconURL) is handled correctly by the component itself.
Also drop the now-unused isImageUrl import.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor(ui): address PR review comments on Icon component

- Move IconProps to Icon.interface.ts per repo convention (greptile
  comment: prop interfaces belong in dedicated .interface.ts files)
- Restore size=40 for image URLs in Certification.component.tsx —
  original 1.13 code used size=28 for named SVG icons and size=40 for
  image URLs; our migration collapsed both to 28 incorrectly

The gitar-bot className comment is already resolved: className lands on
<img> (not <span>) since the span-size fix commit.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(ui): remove padding from .certification-icon

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
ShaileshParmar11 pushed a commit that referenced this pull request Aug 27, 2026
* fix(ui): render icon/image URLs by real load outcome instead of regex pre-validation (#31982)

* fix(ui): render icon/image URLs by real load outcome instead of regex pre-validation

* lint fix

* addressed gitar comment

* addressed gitar comment

* lint fix

* fix(ui): resolve cached-image race in Icon and move IconProps to interface file (#32067)

* fix(ui): resolve cached-image race in Icon and move IconProps to interface file

* lint fix

* fix(ui): apply icon-image classes to the <img> instead of its wrapper span (#32110)

* fix(ui): apply icon-image classes to the <img> instead of its wrapper span

* addressed gitar comment

* lint fix

* unit test fix

* fix(playwright): select Collate SaaS Runner before password fill in ServiceCreationPermissions (#32112)

* fix(playwright): select Collate SaaS Runner before filling password in ServiceCreationPermissions test

When the default runner is Remote Runner the form validation requires
passwords to start with the secret: prefix; switching to Collate SaaS
Runner before submitting removes that requirement so the test can use a
plain-text password value.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(playwright): move runner selection before password fill to prevent blur-time validation error

RJSF customValidate can fire on field blur; selecting Collate SaaS Runner
after the password is typed means the secret: prefix validation may
trigger while Remote Runner is still active. Select the runner first so
the error is never recorded.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>

* fix(ui): Renamed context center Dashboard to Overview

* lint fix

* playwright fix

* lint fix

* Rename i18n key from what-should-ask-collate-remember to what-should-ai-remember

Replace the old product-branded key with a generic AI key across the component and all 20 locale files, and move the key from the label namespace to the message namespace where the component expects it.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* lint fix

* class based approach

* lint fix

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>

This branch was previously deployed

1 inactive deployment
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 UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add fetch URL validation for certification icon validation

3 participants