Skip to content

Add new loading mode: local #6127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

isaacroldan
Copy link
Contributor

@isaacroldan isaacroldan commented Jul 17, 2025

WHY are these changes introduced?

To improve the handling of unknown extension types in local development mode, allowing the app to load successfully even when unknown extension types are present.

WHAT is this pull request doing?

  • Adds a new local mode to the AppLoaderMode type, which ignores errors for unknown extension types
  • Updates the localAppContext function to use the new local mode instead of strict

How to test your changes?

For know extensions only accessible when authenticated:

  1. Create a local app with an admin_link extensions
  2. Both app build and app deploy should work. build will ignore the admin_link extension

For completely unknown extensions:

  1. Create a local app with an admin_link extension.
  2. Change the type of the extension to "invalid_type"
  3. app build still works because it ignore unknown extensions, app deploy should crash.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@isaacroldan isaacroldan marked this pull request as ready for review July 17, 2025 15:16
@isaacroldan isaacroldan requested a review from a team as a code owner July 17, 2025 15:16

This comment has been minimized.

@isaacroldan isaacroldan force-pushed the 07-17-add_new_loading_mode_local branch 2 times, most recently from c3318c7 to 29f77cf Compare July 17, 2025 15:23
@isaacroldan isaacroldan requested a review from a team as a code owner July 17, 2025 15:23
@isaacroldan isaacroldan force-pushed the 07-17-add_new_loading_mode_local branch from 29f77cf to 5349676 Compare July 17, 2025 15:32
Copy link
Contributor

github-actions bot commented Jul 17, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
78.07% (+0.12% 🔼)
13002/16655
🟡 Branches
72.29% (+0.21% 🔼)
6339/8769
🟡 Functions
78.17% (+0.08% 🔼)
3370/4311
🟡 Lines
78.47% (+0.13% 🔼)
12311/15688
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / graphql-errors.ts
0% 0% 0% 0%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app-context.ts
96.88%
88% (-1.29% 🔻)
100% 96.77%
🔴
... / base-command.ts
36.36% (-13.64% 🔻)
0% 100%
36.36% (-13.64% 🔻)

Test suite run success

3028 tests passing in 1311 suites.

Report generated by 🧪jest coverage report action from 5349676

@@ -466,6 +472,8 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS

if (specification) {
usedKnownSpecification = true
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not your change, but usedKnownSpecification seems pointless in this method since if there is no specification we always return early from the method, so there's no need to be checking usedKnownSpecification further down.

Copy link
Contributor Author

@isaacroldan isaacroldan Jul 18, 2025

Choose a reason for hiding this comment

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

Actually, that's still useful when not using the local mode. It makes sense for the report mode.

@@ -466,6 +472,8 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS

if (specification) {
usedKnownSpecification = true
} else if (this.mode === 'local') {
return undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a good sense of how the contents of the loaded app (the extensions list) are used throughout the CLI? If we knew this was only used by build it would be safer, but this loader could be used anywhere - how can we guarantee that all usages (current and future) will be OK with skipping an unknown extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is tricky, for instance the only command that uses the report loader mode is the app info command, because we want to surface errors but still load the app.
But we can't prevent other commands from using that loading mode (unless we add a special eslint rule I guess). That's why we called it unsafeReportMode.

In this case, the local mode will only be used when using the localAppContext, which should only be used by unauthenticated commands (app build and app function).

@@ -162,6 +161,6 @@ export async function localAppContext({
directory,
userProvidedConfigName,
specifications,
mode: unsafeReportMode ? 'report' : 'strict',
mode: 'local',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think since we dont' know who is using localAppContext, it's dangerous to assume we always want local here. I think we should pass an argument into localAppContext (similar to how it was before) so that the command can determine whether it's safe to skip unknown extensions when loading the local app. Since there might be cases where a default value of local is wrong and then bad things happen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Umm, my assumption was that if this is a local app, the expectation is that only local specifications can be used, and we should never crash in that case.

Since there might be cases where a default value of local is wrong and then bad things happen

I can't imagine a case where you would want to load the app with the local specs, but crash if there is an unknown extension 🤔. Right now the default mode is strict and that's what's causing the issues that made us make this change

The way I see it:
localAppContext -> local mode
linkedAppContext -> strict or report modes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants