Skip to content

fix(data-products): port pickers hide assets that can't be ports and show why a port is rejected - #36729

Merged
anuj-kumary merged 5 commits into
mainfrom
anuj-kumary/asset-input/output-port-conflict
Nov 3, 2026
Merged

anuj-kumary merged 5 commits into
mainfrom
anuj-kumary/asset-input/output-port-conflict

Conversation

@anuj-kumary

@anuj-kumary anuj-kumary commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #36802

Adding an asset as a data product port failed with a generic "Error while adding assets!" toast whenever the backend rejected it. Two reports:

  1. Output port: the asset was already an input port of the same data product.
  2. Input port: the picked result was a tableColumn, which can never be a port.

The backend is right to reject both. The UI offered assets it can't add and hid the reason:

  • an all-failed bulk add returns 400 with a BulkOperationResult whose reasons are in failedRequest[].message;
  • the toast only reads response.data.message, so it fell back to the generic text.

Changes

  • Port pickers hide assets of the other port kind (InputOutputPortsTab.component.tsx, DataProductPureUtils.ts).
    • On Add Port, the tab fetches the other kind's ports and excludes them from the picker search.
    • The exclusion is an ES ids query; id is text-mapped in most indexes, so a terms on id never matches.
    • Capped at the API max of 1000 ports. Past that, the save still rejects inline.
  • Rejected rows are shown inline instead of a generic toast (useAssetSelectionState.ts).
    • A 400 carrying failedRequest sets the selection's failed status, so each card shows its backend reason.
    • It's the shared save handler, so the data product Assets drawer and the Metric assets modal get the same fix.
    • Glossary, domain and tag pickers never return this shape, so they're unchanged.
  • Clearer backend message (DataProductRepository.PortRules.alreadyOpposite).
    • Before: Asset 'X' is already part of input ports and cannot be added to outputPorts
    • After: Asset 'X' is already an input port of this data product; an asset cannot be both an input and an output port
    • The same text is used when a held port change is approved.
    • No API, status-code or schema change.

Column results (report 2): on main, #35740 already drops tableColumn from both port pickers (PORT_ASSETS_FILTER). That isn't on 2.0, so a 2.0.x backport needs that hunk plus this PR.

Type of change:

  • Bug fix

High-level design:

N/A — bug fix.

Tests:

Use cases covered

  • Output port picker does not list an asset that is already an input port, and still lists the data product's other assets.
  • Input port picker does not list an asset that is already an output port.
  • Adding a port the backend rejects shows the backend reason on that asset card, with no generic toast.
  • Backend returns the new message for input→output and output→input, on direct add and when a held change is approved.

Unit tests

  • useAssetSelectionState.test.ts: an all-failed 400 shows each row's reason inline, with no toast.
  • InputOutputPortsTab.component.test.tsx: the output port picker's query excludes the input port ids.
  • Jest, AssetsSelectionModal + InputOutputPortsTab: 9 suites, 125/125 passed.

Backend integration tests

  • Updated for the new message:
    • DataProductResourceIT.test_assetCannotBeBothInputAndOutputPort
    • DataProductResourceIT.test_assetCannotBeAddedToInputIfAlreadyOutputPort
    • WorkflowDefinitionResourceIT.test_dataProductPortCannotBecomeBothKindsThroughOneRequest

Local Java test run: PASSED

  • Commit: c4dc42a24f05 (base origin/main)
  • Finished: 2026-10-31 08:32 UTC · 5.4 min
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-service (2 classes) 2 35 0 0 1.8 passed
integration mysql-elasticsearch · parallel passed in CI
integration mysql-elasticsearch · isolated passed in CI
integration cache-tests · parallel 1 9 0 1 3.6 passed

Playwright (UI) tests

  • Added InputOutputPorts.spec.ts › Output port picker hides assets that are already input ports.
    • It checks that a sibling asset is listed, so the "input port is not listed" check can't pass on an empty list.
    • Stable: 3/3 on --repeat-each=3.
  • Ran against this branch's UI (Vite) with a local 2.0.0-SNAPSHOT backend:
npx playwright test playwright/e2e/Pages/InputOutputPorts.spec.ts --project=chromium --no-deps --workers=2 --retries=0
  44 passed (2.8m)

Manual testing performed

  1. On a local backend, created a data product and added a table as an input port through the API.
  2. Confirmed the picker's search with the new must_not: [{ ids }] filter returns 0 hits for that table, and 1 without it.
  3. Replayed the customer HAR:
    • PUT …/inputPorts/add with a tableColumn returns 400 with failedRequest[0].message;
    • that is the response shape the new inline handling reads.

UI screen recording:

Recorded on this branch's UI (c4dc42a24f0), Vite against a local OpenMetadata 2.0.0-SNAPSHOT backend.

1. Output port picker hides assets that are already input ports

The first table is an input port, and both tables are data product assets. Only the second table is offered.

Output port picker

2. Input port picker hides assets that are already output ports

The first table is an output port. Searching for its exact name doesn't return it. Searching for the other table does.

Input port picker

3. A rejected save shows the reason on the asset card

The table was made an input port through the API while the output picker was open, then saved. The backend returns 400. The drawer shows the reason on that card and a "1 Error" count, with no generic "Error while adding assets!" toast.

The recording backend doesn't include this PR's Java change, so the text shown is the old wording. With this PR it reads "…is already an input port of this data product; an asset cannot be both an input and an output port".

Inline error

4. A different table as each port: both save

One table is added as an input port and a different table as an output port, both through the pickers. Both are saved and listed.

Both ports added

Still screenshots

Output port picker
Input port picker
Inline error
Both ports added

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation> — pending the support ticket.
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above — pending the support ticket.
  • 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. (No schema change.)
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

… show why a port is rejected

- Output port picker hides the data product's input ports, input port picker
  hides its output ports (ES `ids` exclusion; `id` is text-mapped).
- Asset selection shows the per-asset reasons of an all-failed bulk add (400
  BulkOperationResult) instead of the generic "Error while adding assets!" toast.
- Clearer backend message: "Asset 'X' is already an input port of this data
  product; an asset cannot be both an input and an output port".
@anuj-kumary
anuj-kumary requested review from a team as code owners October 30, 2026 17:45
@anuj-kumary
anuj-kumary requested a review from harshach October 30, 2026 17:45
@github-actions

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 added the UI UI specific issues label Oct 30, 2026
@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!

@anuj-kumary anuj-kumary self-assigned this Oct 30, 2026
@anuj-kumary anuj-kumary added skip-pr-checks Bypass PR metadata validation check safe to test Add this label to run secure Github workflows on PRs labels Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 6 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), 6 warning(s) across 2 changed file(s).

Count Rule
2 openmetadata-imports/no-lower-layer-page-imports
2 react-hooks/exhaustive-deps
1 openmetadata-imports/review-sequential-api-calls
1 openmetadata-imports/no-impure-pure-utils
All findings
Location Rule Message
🟡 src/components/DataAssets/AssetsSelectionModal/useAssetSelectionState.ts:48: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/components/DataAssets/AssetsSelectionModal/useAssetSelectionState.ts:199:5 react-hooks/exhaustive-deps React Hook useCallback has a missing dependency: 'activeFilter'. Either include it or remove the dependency array.
🟡 src/components/DataAssets/AssetsSelectionModal/useAssetSelectionState.ts:270:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'fetchEntities'. Either include it or remove the dependency array.
🟡 src/components/DataAssets/AssetsSelectionModal/useAssetSelectionState.ts:443:15 openmetadata-imports/review-sequential-api-calls Review these sequential API requests. If they are independent, start them together with Promise.all/Promise.allSettled; keep sequencing only when data-dependent
🟡 src/utils/DataProductPureUtils.ts:15:1 openmetadata-imports/no-impure-pure-utils Pure utilities must not depend on React, UI, state, hooks, pages, or REST clients. Move orchestration/rendering out or move shared types to a lower layer.
🟡 src/utils/DataProductPureUtils.ts:15: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.

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

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 80%
80.77% (135636/167917) 67.58% (48557/71841) 70.61% (27330/38701)

A late port fetch for one picker could overwrite the other picker's
exclusion list when both Add Port buttons were clicked before the first
fetch returned.
…ort-conflict' into anuj-kumary/asset-input/output-port-conflict
@gitar-bot

gitar-bot Bot commented Oct 31, 2026

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

🟡 Medium risk · Port-picker exclusions and inline bulk-error handling change selection behavior; failed or capped lookups could leave incompatible assets selectable and cause rejected saves.

Port pickers now exclude assets that are already the opposite port kind, and rejected adds show the backend reason inline instead of a generic error toast. A race where one shared exclusion list could reach the wrong picker was resolved. No open issues found.

✅ 1 closed
✅ Edge Case: Both port pickers share one oppositePortIds, so a late response can reach the wrong picker

📄 openmetadata-ui/src/main/resources/ui/src/components/DataProducts/InputOutputPortsTab/InputOutputPortsTab.component.tsx:396 📄 openmetadata-ui/src/main/resources/ui/src/components/DataProducts/InputOutputPortsTab/InputOutputPortsTab.component.tsx:420-434 📄 openmetadata-ui/src/main/resources/ui/src/components/DataProducts/InputOutputPortsTab/InputOutputPortsTab.component.tsx:519-533
handleAddInputPort and handleAddOutputPort each wait for a network fetch before opening their drawer. Both write into the same oppositePortIds state, and neither button is disabled while its fetch is in flight. If the user clicks Add input port and then Add output port before the first fetch returns, both drawers open and whichever response arrives last sets the ids for both filters. For example, the output picker could end up excluding output-port ids instead of input-port ids. That brings back the case this PR is meant to prevent, where the picker lists an asset the save will reject. Nothing shows while the fetch runs, so on a slow network the button looks unresponsive and invites the double click that triggers this. Fix: keep separate state for each picker (inputPickerExcludedIds / outputPickerExcludedIds), or record which kind the load was for and drop responses that don't match. Also disable the button or show a loading state while the fetch runs.

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

@sonarqubecloud

Copy link
Copy Markdown

@anuj-kumary

Copy link
Copy Markdown
Member Author

Local Java test run: PASSED — details

  • Commit: c4dc42a24f05 (base origin/main)
  • The summary is in the PR description.

Tests run locally

  • unit · openmetadata-service (2 classes): EntityRepositoryTagCacheTest (8 passed), RuleEvaluatorTest (27 passed)
  • integration · mysql-elasticsearch · parallel: every lane class, in this CI run
  • integration · mysql-elasticsearch · isolated: every lane class, in this CI run
  • integration · cache-tests · parallel: OneTransactionFlushAtomicityIT (8 passed, 1 skipped)
Why these tests
  • area domains ← openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java
  • called from entity DataProduct ← openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java
  • called from entity Domain ← openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java
  • changed test ← openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java, openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/WorkflowDefinitionResourceIT.java
  • entity DataProduct ← openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java
  • smoke ← code other than a test class changed
Commands
mvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=EntityRepositoryTagCacheTest,RuleEvaluatorTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=ConfigResourceIT,DataProductDomainMigrationIT,DataProductResourceIT,DatabaseSmokeIT,DomainAssetsColumnExclusionIT,DomainBulkAssetsDryRunIT,DomainIsolationIT,DomainMoveApprovalAuthorizationIT,DomainReassignmentAuthorizationIT,DomainRecreateSameNameIT,DomainResourceIT,GlossaryTermResourceIT,MultiDomainHasDomainIT,SeedDataPresenceIT,TableResourceIT,TestCaseCsvDomainIsolationIT,UserResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=WorkflowDefinitionResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=parallel -Dit.test=OneTransactionFlushAtomicityIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

@anuj-kumary
anuj-kumary enabled auto-merge November 2, 2026 05:28
@anuj-kumary
anuj-kumary added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-11-02T09:35:03Z)

Blocked the queue: integration-tests-postgres-elasticsearch-redis

@sonika-shah
sonika-shah added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-11-02T17:06:24Z)

Blocked the queue: integration-tests-mysql-elasticsearch

@anuj-kumary
anuj-kumary added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 97af5ab Nov 3, 2026
102 checks passed
@anuj-kumary
anuj-kumary deleted the anuj-kumary/asset-input/output-port-conflict branch November 3, 2026 08:14
anuj-kumary added a commit that referenced this pull request Nov 4, 2026
…show why a port is rejected (#36729) (#36984)

* fix(data-products): keep port pickers to assets that can be ports and show why a port is rejected

- Output port picker hides the data product's input ports, input port picker
  hides its output ports (ES `ids` exclusion; `id` is text-mapped).
- Asset selection shows the per-asset reasons of an all-failed bulk add (400
  BulkOperationResult) instead of the generic "Error while adding assets!" toast.
- Clearer backend message: "Asset 'X' is already an input port of this data
  product; an asset cannot be both an input and an output port".

* fix(data-products): keep each port picker's exclusions separate

A late port fetch for one picker could overwrite the other picker's
exclusion list when both Add Port buttons were clicked before the first
fetch returned.

* chore(ui): organize imports in InputOutputPortsTab test

2.0 backport notes:
- Includes the column exclusion (PORT_ASSETS_FILTER) from #35740, which 2.0 lacks.
- Adds ids to QueryFieldInterface, as on main, so the ids exclusion type-checks.
- Drops the held-port-change test edit (WorkflowDefinitionResourceIT); 2.0 has no port approvals.
- InputOutputPortsTab test keeps only the port picker suite.

(cherry picked from commit 97af5ab)
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 skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data product Input/Output port pickers offer assets the API rejects, and the UI hides the actual error

3 participants