Skip to content

fix(ui): only embed http(s) learning resource URLs - #36300

Merged
harsh-vador merged 3 commits into
mainfrom
fix/learning-resource-url-scheme
Oct 27, 2026
Merged

harsh-vador merged 3 commits into
mainfrom
fix/learning-resource-url-scheme

Conversation

@harsh-vador

@harsh-vador harsh-vador commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #36299

The Learning Center's video and Storylane players loaded a resource's source URL into their embedded frame unchanged whenever it was not a YouTube or Vimeo link. Now both accept only an http(s) URL, the same rule PdfViewer and openUrlInNewTab already apply to this field through getSafeHttpUrl, and show the existing label.invalid-url state otherwise. The learning-resource form's source URL field uses the same check, so such a value can't be saved from the UI.

  • VideoPlayer: getSafeHttpUrl runs first, and only an accepted URL reaches getEmbedUrl. The YouTube and Vimeo embed rewriting is unchanged. Without a safe URL, no frame is rendered.
  • StorylaneTour: the same guard on its frame src.
  • useLearningResourceFields: sourceUrl is validated with getSafeHttpUrl instead of the shared isValidUrl. isValidUrl itself is unchanged because theme settings use it too. Every source URL placeholder in Learning.constants.ts is already https://….
3-player-embeds-youtube 2-player-blocks-javascript-url 1-form-rejects-javascript-url

Type of change:

  • Bug fix

High-level design:

N/A, small change.

Tests:

Use cases covered

  • A video or Storylane resource whose URL is not http(s) (javascript:, data:, or a string that does not parse) shows the invalid-URL state, and no frame is rendered.
  • An http(s) URL embeds as before, including the YouTube and Vimeo rewriting and the unknown-provider passthrough.
  • Saving a learning resource whose source URL is not http(s) is blocked with label.invalid-url.

Unit tests

  • Added cases to VideoPlayer.test.tsx, StorylaneTour.test.tsx and LearningResourcesSettings.test.tsx. In VideoPlayer.test.tsx, "should handle invalid URL gracefully" now expects the invalid-URL state instead of a frame whose src is the unparsed string.
  • jest src/components/Learning/ResourcePlayer src/components/discovery/personal-space/Profile/tabs/platform-settings: 30 suites, 268 tests pass.
  • Negative control: with only the three source files reverted to main, 8 of the new or updated tests fail. They are the VideoPlayer, StorylaneTour and form cases.
  • eslint and prettier are clean on the changed files. tsc --noEmit reports no errors in them.

Backend integration tests

  • Not applicable (no backend API changes). make java_affected: no Java tests are impacted.

Playwright (UI) tests

Not run locally. make playwright_affected selects 22 specs and reports impact-map gaps. They run in this PR's CI.

Manual testing performed

I ran this branch's UI (vite) against a local server and signed in as admin, on Settings → Preferences → Learning Resource:

  1. Add Resource with a non-http(s) Source URL: saving is blocked with "Invalid URL".
  2. Preview a video resource whose stored URL is not http(s). I rewrote it in the browser's API response only, so nothing was stored. The player shows "Invalid URL" and renders no frame.
  3. Preview a normal YouTube resource: it embeds as before (https://www.youtube.com/embed/<id>…).

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issues were found.

Summary

Restricts learning-resource URLs to HTTP(S).

  • Video and Storylane players check source URLs before rendering frames.
  • Learning resource forms accept only HTTP(S) source URLs.
  • Playwright selection maps link two more UI files to their existing specs.

No actionable new issues or repository-rule violations were found. No previous review threads were supplied. Tests and browser checks were not run; local UI capture was blocked by missing dependencies.

Reviews (2) · Last reviewed commit: "fix(ui): put the invalid-URL padding on ..." · Reviewed by Greptile

VideoPlayer and StorylaneTour loaded the resource's source URL into their
iframes as-is when it was not a YouTube/Vimeo link. Both now accept only an
http(s) URL, the same rule PdfViewer and openUrlInNewTab already apply via
getSafeHttpUrl, and show the invalid-URL state otherwise. The learning
resource form now validates the source URL the same way.
@harsh-vador
harsh-vador requested a review from a team as a code owner October 27, 2026 05:34
@harsh-vador harsh-vador added the UI UI specific issues label Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

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

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 994 → 996
- 2 added, 0 removed, 0 changed spec-list

New source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/applications/AppScheduleEdit.tsx
  openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/Profile/tabs/platform-settings/search/FieldValueBoostFields.tsx

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@harsh-vador harsh-vador added the safe to test Add this label to run secure Github workflows on PRs label Oct 27, 2026
@harsh-vador harsh-vador self-assigned this Oct 27, 2026
…aphy

Per ADR:2026-10-11-migrated-antd-components-adopt-core-styling, callers
handle layout but do not set padding on a core component through className.
@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 79%
79.75% (131257/164583) 66.26% (46295/69864) 69.21% (26270/37953)

@gitar-bot

gitar-bot Bot commented Oct 27, 2026

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

🟡 Medium risk · Rejecting non-HTTP(S) learning-resource URLs prevents script-capable embeds, but may make existing non-web resources unavailable.

Restricts Learning Center video and Storylane embeds and the learning-resource source URL field to http(s) URLs, so javascript: and other non-web values are blocked. Padding for the invalid-URL state was moved onto a wrapper, addressing the finding that it was set on core Typography. No open issues found.

✅ 1 closed
✅ Quality: Padding set via className on core Typography breaks the styling rule

📄 openmetadata-ui/src/main/resources/ui/src/components/Learning/ResourcePlayer/VideoPlayer.component.tsx:106-112 📄 openmetadata-ui/src/main/resources/ui/src/components/Learning/ResourcePlayer/StorylaneTour.component.tsx:37-43
Both new invalid-URL states add padding by passing className="tw:p-4" to the core Typography component. The repo's core-components rule (ADR 2026-10-11) says callers must not set padding, border, background or text styles on a core component through className. The caller should only handle layout. To fix this, put the padding on a plain wrapper element and leave Typography with only as/size props.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

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

@harsh-vador
harsh-vador enabled auto-merge October 27, 2026 06:15
@sonarqubecloud

Copy link
Copy Markdown

@harsh-vador
harsh-vador added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 8d53dbe Oct 27, 2026
85 of 87 checks passed
@harsh-vador
harsh-vador deleted the fix/learning-resource-url-scheme branch October 27, 2026 07:55
harsh-vador added a commit that referenced this pull request Nov 3, 2026
…) (#36934)

* fix(ui): only embed http(s) learning resource URLs (backport 2.0 #36300)

Video and Storylane resources pass source.url through getSafeHttpUrl
before it becomes the iframe src, and show the invalid-URL state
instead of a frame when it is not an http(s) URL.

Ported by hand: 2.0 predates the player refactor on main, so the
change is applied to 2.0's components. The learning-resource form
change from #36300 is not needed on 2.0, whose form already validates
the source URL with antd's url rule.

(cherry picked from commit 8d53dbe)

* fix(ui): link only http(s) URLs in the article viewer

Backport of the ArticleViewer change in #36156 to 2.0: the "open in new
tab" link on an article that failed to load uses getSafeHttpUrl, so a
non-http(s) source URL renders no href.

(cherry picked from commit ca9b8c0, ArticleViewer hunk only)
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.

Learning resource players should only embed http(s) source URLs

2 participants