Skip to content

fix(x2a): bitbucket RepoUrlPicker wrapper#2768

Merged
mareklibra merged 2 commits intoredhat-developer:mainfrom
eloycoto:Bitbucket
Apr 15, 2026
Merged

fix(x2a): bitbucket RepoUrlPicker wrapper#2768
mareklibra merged 2 commits intoredhat-developer:mainfrom
eloycoto:Bitbucket

Conversation

@eloycoto
Copy link
Copy Markdown
Contributor

This is a wrapper around RepoUrlPicker that it's a hotfix for the following issue which gives enough context:

backstage/backstage#33887

Fix FLPATH-3887

@rhdh-gh-app
Copy link
Copy Markdown

rhdh-gh-app bot commented Apr 14, 2026

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-x2a
  • @red-hat-developer-hub/backstage-plugin-x2a

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
app workspaces/x2a/packages/app none v0.0.0
@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-x2a workspaces/x2a/plugins/scaffolder-backend-module-x2a none v0.3.0
@red-hat-developer-hub/backstage-plugin-x2a workspaces/x2a/plugins/x2a none v1.2.0

Copy link
Copy Markdown
Contributor

@elai-shalev elai-shalev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good considering it's a hack. I would add some tests for the RepoUrlPickerWithBitbucketFix component. Those would likely break once backstage version is updated (if it includes fix) and would signify we need to fix here.

Comment on lines +86 to +88
if (innerProp === 'type') {
return 'bitbucket';
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we assume this part will change / be removed once the bug is resolved, correct? as they may decouple bitbucketCloud and bitbucketServer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yuup

The Owner should be your SCM (Source Code Management) username. The repository name should be a name that already exists in your SCM account. It will be populated by converted Ansible sources and intermediary artifacts.
type: string
ui:field: RepoUrlPicker
ui:field: X2ARepoUrlPicker
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A brief comment that this is a workaround for BitBucker will be helpful in the future.

@mareklibra
Copy link
Copy Markdown
Member

This is probably the fastest way to get a fix and the only one for RHDH 1.9.
Anyway, this will most probably break in RHDH 1.10 - can you create a jira to track the need for retest/replacements?

Tests for the wrapIntegrationsApi will be helpful.

This is a wrapper around RepoUrlPicker that it's a hotfix for the
following issue which gives enough context:

backstage/backstage#33887

Fix FLPATH-3887

Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
Signed-off-by: Eloy Coto <eloy.coto@acalustra.com>
@sonarqubecloud
Copy link
Copy Markdown

@eloycoto eloycoto marked this pull request as ready for review April 15, 2026 14:16
@rhdh-qodo-merge
Copy link
Copy Markdown

rhdh-qodo-merge bot commented Apr 15, 2026

Code Review by Qodo

🐞 Bugs (1)   📘 Rule violations (0)   📎 Requirement gaps (0)
🐞\ ☼ Reliability (1)

Grey Divider


Remediation recommended

1. Import-time throw crashes app 🐞
Description
RepoUrlPickerWithBitbucketFix.tsx throws during module initialization if it can’t extract the
RepoUrlPicker component via internal component-data, which can happen if Backstage changes that
internal key/structure. Because this module is imported unconditionally by the plugin entrypoints,
the exception prevents the entire x2a frontend plugin (and any app importing it) from loading.
Code

workspaces/x2a/plugins/x2a/src/scaffolder/RepoUrlPickerWithBitbucketFix.tsx[R50-61]

+const FIELD_EXTENSION_KEY = 'scaffolder.extensions.field.v1';
+const fieldExtensionData = getComponentData<FieldExtensionOptions>(
+  createElement(RepoUrlPickerFieldExtension),
+  FIELD_EXTENSION_KEY,
+);
+
+if (!fieldExtensionData?.component) {
+  throw new Error(
+    'Failed to extract RepoUrlPicker component from RepoUrlPickerFieldExtension. ' +
+      'The Backstage scaffolder field extension data key may have changed.',
+  );
+}
Evidence
The wrapper performs component extraction at module scope and throws if the internal metadata is
missing, so the error occurs at import time (before React rendering). Since the plugin imports this
wrapper via its scaffolder barrel, any app importing the x2a plugin package will evaluate this
module during startup and can fail to load if the extraction fails.

workspaces/x2a/plugins/x2a/src/scaffolder/RepoUrlPickerWithBitbucketFix.tsx[50-61]
workspaces/x2a/plugins/x2a/src/plugin.ts[22-28]
workspaces/x2a/packages/app/src/App.tsx[56-61]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`RepoUrlPickerWithBitbucketFix.tsx` executes `getComponentData(...)` and throws at **module import time** if the `RepoUrlPickerFieldExtension` metadata key changes or is unavailable. That makes the whole plugin/app fail to load before any error boundary can handle it.

### Issue Context
This wrapper is explicitly a temporary hack for upstream behavior, but the current implementation couples app startup to an internal Backstage component-data key (`scaffolder.extensions.field.v1`). Any upstream refactor (or packaging change) can turn into a hard startup crash.

### Fix Focus Areas
- workspaces/x2a/plugins/x2a/src/scaffolder/RepoUrlPickerWithBitbucketFix.tsx[47-63]
- workspaces/x2a/plugins/x2a/src/scaffolder/RepoUrlPickerWithBitbucketFix.tsx[120-147]

### Suggested fix approach
- Remove the module-scope extraction + throw.
- Prefer a safe runtime approach, e.g.:
 - Render `RepoUrlPickerFieldExtension` directly inside the scoped `<ApiProvider>` (if it is a renderable component with the right props), avoiding `getComponentData` entirely; **or**
 - Move the extraction into the component body (or a lazily-evaluated helper) and handle failures gracefully (render an error state / fallback) instead of throwing during import.
- Ensure the failure mode is localized to the field extension render path (not app startup).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@rhdh-qodo-merge
Copy link
Copy Markdown

Review Summary by Qodo

Add RepoUrlPicker wrapper to fix Bitbucket type resolution in scaffolder

🐞 Bug fix 🧪 Tests ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Adds X2ARepoUrlPickerExtension wrapper to fix Bitbucket Cloud/Server type mismatch in Backstage
  scaffolder
• Wraps scmIntegrationsApi to remap bitbucketCloud/bitbucketServer types to bitbucket for
  proper rendering
• Includes comprehensive unit tests for type remapping and integration preservation
• Updates templates and app configuration to use new X2ARepoUrlPicker field extension
• Adds required dependencies (@backstage/core-app-api, @backstage/integration-react,
  @backstage/plugin-scaffolder)
Diagram
flowchart LR
  A["Backstage RepoUrlPicker"] -->|type mismatch| B["bitbucketCloud/bitbucketServer"]
  C["X2ARepoUrlPickerExtension"] -->|wraps| A
  C -->|intercepts| D["scmIntegrationsApi"]
  D -->|remaps to| E["bitbucket type"]
  E -->|renders| F["BitbucketRepoPicker"]
Loading

Grey Divider

File Changes

1. workspaces/x2a/plugins/x2a/src/index.ts ✨ Enhancement +6/-1

Export new X2ARepoUrlPickerExtension component

workspaces/x2a/plugins/x2a/src/index.ts


2. workspaces/x2a/plugins/x2a/src/plugin.ts ✨ Enhancement +21/-1

Create X2ARepoUrlPickerExtension scaffolder field extension

workspaces/x2a/plugins/x2a/src/plugin.ts


3. workspaces/x2a/plugins/x2a/src/scaffolder/RepoUrlPickerWithBitbucketFix.tsx 🐞 Bug fix +148/-0

Implement RepoUrlPicker wrapper with Bitbucket type fix

workspaces/x2a/plugins/x2a/src/scaffolder/RepoUrlPickerWithBitbucketFix.tsx


View more (6)
4. workspaces/x2a/plugins/x2a/src/scaffolder/RepoUrlPickerWithBitbucketFix.test.ts 🧪 Tests +118/-0

Add comprehensive tests for type remapping logic

workspaces/x2a/plugins/x2a/src/scaffolder/RepoUrlPickerWithBitbucketFix.test.ts


5. workspaces/x2a/plugins/x2a/src/scaffolder/index.ts ✨ Enhancement +1/-0

Export RepoUrlPickerWithBitbucketFix component

workspaces/x2a/plugins/x2a/src/scaffolder/index.ts


6. workspaces/x2a/packages/app/src/App.tsx ✨ Enhancement +2/-0

Register X2ARepoUrlPickerExtension in scaffolder routes

workspaces/x2a/packages/app/src/App.tsx


7. workspaces/x2a/plugins/scaffolder-backend-module-x2a/templates/conversion-project-template.yaml ⚙️ Configuration changes +10/-2

Update template fields to use X2ARepoUrlPicker extension

workspaces/x2a/plugins/scaffolder-backend-module-x2a/templates/conversion-project-template.yaml


8. workspaces/x2a/plugins/x2a/package.json Dependencies +3/-1

Add required Backstage dependencies for wrapper implementation

workspaces/x2a/plugins/x2a/package.json


9. workspaces/x2a/plugins/x2a/report.api.md 📝 Documentation +3/-0

Document public X2ARepoUrlPickerExtension API export

workspaces/x2a/plugins/x2a/report.api.md


Grey Divider

Qodo Logo

@rhdh-qodo-merge rhdh-qodo-merge bot added enhancement New feature or request Tests Bug fix labels Apr 15, 2026
@mareklibra mareklibra merged commit d8c241a into redhat-developer:main Apr 15, 2026
11 checks passed
eloycoto added a commit to eloycoto/rhdh-plugins that referenced this pull request Apr 17, 2026
eloycoto added a commit to eloycoto/rhdh-plugins that referenced this pull request Apr 17, 2026
eloycoto added a commit to eloycoto/rhdh-plugins that referenced this pull request Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug fix enhancement New feature or request Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants