fix(backend-dynamic-feature-service): fall back to main from alpha#34535
Conversation
Changed Packages
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes dynamic backend plugin loading so that when an alpha package.json exists but doesn’t expose a dynamic plugin entrypoint, the loader falls back to the main package export instead of marking the plugin as failed.
Changes:
- Refactors plugin loading to try multiple entrypoints (alpha first, then main) and resolves installers via a helper.
- Adds unit + integration coverage for the alpha-fallback behavior.
- Adds a fixture dynamic plugin that has an alpha export with only supplementary APIs plus a changeset entry.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backend-dynamic-feature-service/src/manager/plugin-manager.ts | Implements “try alpha then main” entrypoint loading and factors installer resolution into helpers. |
| packages/backend-dynamic-feature-service/src/manager/plugin-manager.test.ts | Adds a unit test ensuring fallback to main when alpha doesn’t provide an entrypoint. |
| packages/backend-dynamic-feature-service/src/features/features.test.ts | Adds an integration test validating fallback behavior and associated logs/scanned package metadata. |
| packages/backend-dynamic-feature-service/src/features/fixtures/dynamic-plugins-root-for-alpha-fallback/test-backend-alpha-fallback-dynamic/package.json | Adds fixture plugin package manifest with main + alpha export mappings. |
| packages/backend-dynamic-feature-service/src/features/fixtures/dynamic-plugins-root-for-alpha-fallback/test-backend-alpha-fallback-dynamic/dist/index.cjs.js | Fixture main entry exporting a backend plugin. |
| packages/backend-dynamic-feature-service/src/features/fixtures/dynamic-plugins-root-for-alpha-fallback/test-backend-alpha-fallback-dynamic/dist/alpha.cjs.js | Fixture alpha entry exporting only supplementary APIs (no installer). |
| packages/backend-dynamic-feature-service/src/features/fixtures/dynamic-plugins-root-for-alpha-fallback/test-backend-alpha-fallback-dynamic/alpha/package.json | Fixture alpha package.json pointing at the alpha bundle. |
| .changeset/fix-dynamic-plugin-alpha-fallback.md | Documents the patch fix and expected loader behavior. |
Dynamic backend plugins with an alpha package.json failed to load when the alpha export only exposed supplementary APIs, even if the main export was valid. The loader now tries the alpha entry first and falls back to the main export when no valid plugin installer is found. Signed-off-by: Stan Lewis <gashcrumb@gmail.com> Assisted-By: Cursor Desktop
c1775a6 to
7005478
Compare
This change adds a temporary patch to update the backend dynamic feature service so that it will also load backend plugins that have an alpha export but do not export the plugin object in that alpha export. The patch is similar to the fix applied in this PR: backstage/backstage#34535 Assisted-By: Cursor Desktop
This change adds a temporary patch to update the backend dynamic feature service so that it will also load backend plugins that have an alpha export but do not export the plugin object in that alpha export. The patch is similar to the fix applied in this PR: backstage/backstage#34535 Assisted-By: Cursor Desktop
This change adds a temporary patch to update the backend dynamic feature service so that it will also load backend plugins that have an alpha export but do not export the plugin object in that alpha export. The patch is similar to the fix applied in this PR: backstage/backstage#34535 Assisted-By: Cursor Desktop
This change adds a temporary patch to update the backend dynamic feature service so that it will also load backend plugins that have an alpha export but do not export the plugin object in that alpha export. The patch is similar to the fix applied in this PR: backstage/backstage#34535 Assisted-By: Cursor Desktop
This change adds a temporary patch to update the backend dynamic feature service so that it will also load backend plugins that have an alpha export but do not export the plugin object in that alpha export. The patch is similar to the fix applied in this PR: backstage/backstage#34535 Assisted-By: Cursor Desktop
freben
left a comment
There was a problem hiding this comment.
Alright, since this is a valuable fix let's merge this with some comments for potential follow-up cleanup. I think it's correct at runtime, which is what's most important.
| }, | ||
| ]; | ||
|
|
||
| if (entryPoints.length === 0) { |
There was a problem hiding this comment.
This can actually never happen now
| if (dynamicPlugin.installer) { | ||
| const entryPoints: Array<{ location: URL; manifest: string }> = [ | ||
| ...(plugin.alphaManifest?.main | ||
| ? [ |
There was a problem hiding this comment.
This could have looked clearer with an if and a push, instead of the ternary+spread
| return dynamicPlugin; | ||
| } | ||
|
|
||
| return dynamicPlugin; |
There was a problem hiding this comment.
I don't think this can technically happen now either, right? The code above seems to always do either continue or throw.
| ): Promise<{ | ||
| installer?: BackendDynamicPlugin['installer']; | ||
| error?: Error; | ||
| }> { |
There was a problem hiding this comment.
This could have been a discriminated union if we wanted some extra clarity
| } | ||
|
|
||
| if (!loadResult.error && index < entryPoints.length - 1) { | ||
| continue; |
There was a problem hiding this comment.
Perhaps a matter of taste, but continue is a bit of a minor smell that can often be rewritten more readably. I think in this case it shadows the fact that the final return can't happen for example.
The overall structure could probably have been
let outcome = load(first);
if (condition && second) {
outcome = load(second);
}
if (outcome is error) ...
return|
Thank you for contributing to Backstage! The changes in this pull request will be part of the |
@freben Sounds good! I'll prepare an update that incorporates your feedback, thanks! |
This change adds a temporary patch to update the backend dynamic feature service so that it will also load backend plugins that have an alpha export but do not export the plugin object in that alpha export. The patch is similar to the fix applied in this PR: backstage/backstage#34535 Assisted-By: Cursor Desktop
…loading Follow-up cleanup after backstage#34535. Use a discriminated union for load results, try alpha before falling back to main, and remove the loop with unreachable branches. Assisted-By: Cursor Desktop Signed-off-by: Stan Lewis <gashcrumb@gmail.com>
|
Have created this PR to address the feedback, think it definitely reads a lot better. Thanks! |
…loading Follow-up cleanup after backstage#34535. Use a discriminated union for load results, try alpha before falling back to main, and remove the loop with unreachable branches. Assisted-By: Cursor Desktop Signed-off-by: Stan Lewis <gashcrumb@gmail.com>
Hey, I just made a Pull Request!
Dynamic backend plugins with an alpha package.json failed to load when the alpha export only exposed supplementary APIs, even if the main export was valid. The loader now tries the alpha entry first and falls back to the main export when no valid plugin installer is found.
Without this fix, attempting to load plugins such as catalog-backend using the backend dynamic feature service will currently fail with an error similar to following message:
Assisted-By: Cursor Desktop
✔️ Checklist
Signed-off-byline in the message. (more info)