Skip to content

Fix schema loading when no default profile#2441

Merged
moelasmar merged 6 commits intoaws:developfrom
laurelmay:fix-no-default-profile
Mar 27, 2021
Merged

Fix schema loading when no default profile#2441
moelasmar merged 6 commits intoaws:developfrom
laurelmay:fix-no-default-profile

Conversation

@laurelmay
Copy link
Contributor

@laurelmay laurelmay commented Dec 3, 2020

The region_name value when a profile does not specify a region or when
there is not a 'default' profile resulted in a crash since
_get_aws_region_choice attempted to perform concatenation using the +
operator (which is undefined for str + NoneType). Using an actual string
formatting method fixes that issue.

Additionally, it is useless to prompt the user whether not to use the
'default' profile since doing so is impossible. They need to be
prompted. Additionally, it is slightly more 'intelligent' to create a
new session after the user has chosen a new profile so that a better
default region can be chosen.

Which issue(s) does this change fix?

No issue was opened.

Why is this change necessary?

The sam init crashes if a user needs to pick a schema and they do not have a default profile or their default profile does not specify a region. (TypeError in _get_aws_region_choice)

How does it address the issue?

Avoids performing a + operation to perform string concatenation.

What side effects does this change have?

Does not prompt the user to accept the defaults if doing so results in region being None. Just moves on to asking the user.

Checklist

  • Write design document (Do I need to write a design document?)
  • Write unit tests
  • Write/update functional tests
  • Write/update integration tests
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@moelasmar moelasmar left a comment

Choose a reason for hiding this comment

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

Can you add unit/integration test cases that cover this change

@laurelmay laurelmay force-pushed the fix-no-default-profile branch from e72f5f0 to 5d09f6c Compare December 31, 2020 22:04
The region_name value when a profile does not specify a region or when
there is not a 'default' profile resulted in a crash since
_get_aws_region_choice attempted to perform concatenation using the `+`
operator (which is undefined for str + NoneType). Using an actual string
formatting method fixes that issue.

Additionally, it is useless to prompt the user whether not to use the
'default' profile since doing so is impossible. They need to be
prompted. Additionally, it is slightly more 'intelligent' to create a
new session after the user has chosen a new profile so that a better
default region can be chosen.
@laurelmay laurelmay force-pushed the fix-no-default-profile branch from 5d09f6c to 3e9ebe9 Compare December 31, 2020 22:10
@laurelmay
Copy link
Contributor Author

@moelasmar: Unit test coverage for the new code path(s) has been added

@CoshUS CoshUS requested a review from moelasmar March 16, 2021 19:38
Base automatically changed from develop to elbayaaa-develop March 25, 2021 21:28
Base automatically changed from elbayaaa-develop to develop March 25, 2021 21:38
@moelasmar moelasmar merged commit 4bf00f3 into aws:develop Mar 27, 2021
moelasmar added a commit to moelasmar/aws-sam-cli that referenced this pull request Jul 1, 2021
The region_name value when a profile does not specify a region or when
there is not a 'default' profile resulted in a crash since
_get_aws_region_choice attempted to perform concatenation using the `+`
operator (which is undefined for str + NoneType). Using an actual string
formatting method fixes that issue.

Additionally, it is useless to prompt the user whether not to use the
'default' profile since doing so is impossible. They need to be
prompted. Additionally, it is slightly more 'intelligent' to create a
new session after the user has chosen a new profile so that a better
default region can be chosen.

Co-authored-by: _sam <3804518+aahung@users.noreply.github.com>
Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants