-
Notifications
You must be signed in to change notification settings - Fork 7
Add logging and remove validation with developer profile querying #488
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
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.
Minor nit in removing some of the validity checking.
private boolean isValidAccountId(final String accountId) { | ||
return accountId != null && accountId.matches("^\\d{12}$"); | ||
return StringUtils.isNotBlank(accountId); | ||
} | ||
|
||
private boolean isValidArn(final String arn) { | ||
return arn != null && arn.matches("^arn:aws:codewhisperer:[a-z]{2}-[a-z]+-\\d:\\d{12}:profile/[A-Z0-9]+$"); | ||
return StringUtils.isNotBlank(arn); | ||
} | ||
|
||
private boolean isValidRegion(final String region) { | ||
return region != null && region | ||
.matches("^[a-z]{2}-(central|north|south|east|west|northeast|southeast|northwest|southwest)-(\\d)$"); | ||
return StringUtils.isNotBlank(region); | ||
} |
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.
Why drop these validations?
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.
None of the other IDEs do it and clients are not expected to. We expect validation to happen on the backend side where an incorrect value should fail with an appropriate message. Also the validity checking was too regex heavy which was leading to invalid states happening on the Eclipse side.
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.
IMO it's fine to not have these check, in most scenarios, users won't touch / modify the cached file (also that's what we expect). We just need to ensure serialize/de-serialize work fine then it should be good enough.
public final String getRegion() { | ||
return identityDetails.region(); | ||
return identityDetails != null ? identityDetails.region() : null; |
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.
nit: iirc, this field is mostly null
, should be more reliable to get region from the arn
https://github.com/aws/aws-toolkit-jetbrains/blob/main/plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/profile/QRegionProfile.kt#L12-L16
Description of changes:
There is not sufficient logging around the developer profile fetching logic in the login flow. This change adds more logging. In addition, unnecessary restrictive validation checks on the stored and returned Q developer profiles has been removed as we want to rely on the backend to give us valid results. Only validation to check the shape of the stored value is now used, if it is incorrect, we expect further calls to the backend to fail with an appropriate message.
Related issue: #485
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.