-
Notifications
You must be signed in to change notification settings - Fork 746
fix(toolkit): handle isCn when region is not initialized to fix extension activation failure #7599
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
Conversation
…sion activation failure
|
| return getComputeRegion()?.startsWith('cn') ?? false | ||
| } catch (e) { | ||
| // If compute region isn't initialized yet, assume we're not in a CN region | ||
| getLogger().debug('isCn called before compute region initialized, defaulting to false') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also log the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review, added error logging as well as unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 of the CI workflow checks are failing seemingly due to a change merged recently and not due to this commit, reference: https://github.com/aws/aws-toolkit-vscode/actions/runs/16175639516/job/45659998532
| // Restore original getComputeRegion if it was stubbed | ||
| if (utils.getComputeRegion.restore) { | ||
| utils.getComputeRegion.restore() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this? I see sandbox.restore() is called in our afterEach, doesn't this already reset all stubs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, not needed necessarily. Added it initially for best practice, but since sandbox is restored in afterEach, underlying stubs should also get cleaned
| } catch (err) { | ||
| getLogger().error(`Error in isCn method: ${err}`) | ||
| return false | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead be throwing the error here? We already handle the known case above by returning false when the region is uninitialized, but this can catch other errors that I'm not sure we should assume returning false for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, the case that throws error is handled already, and i didnt find any error cases that could result from the getComputeRegion method, hence it looks safe to not throw error back
|
/retryBuilds |
Problem
With updating Toolkit version to latest in SMUS CodeEditor Spaces, observing Toolkit throws an error as attached in screenshot below with error message
Solution
isCn()resilient to uninitialized state and return a default valuefeature/xbranches will not be squash-merged at release time.