Skip to content

Redundant check in hasRequiredEndpointDiscovery in endpoint discovery code #3755

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

Closed
trivikr opened this issue May 7, 2021 · 1 comment
Closed
Labels
closed-for-staleness feature-request A feature should be added or improved.

Comments

@trivikr
Copy link
Member

trivikr commented May 7, 2021

Is your request related to a problem? Please describe.
Not a problem, but there's a check for hasRequiredEndpointDiscovery in endpoint discovery code under switch statement which is always expected to be false.

switch (isEndpointDiscoveryRequired) {
case 'OPTIONAL':
if (isEnabled || hasRequiredEndpointDiscovery) {
// For a given service; if at least one operation requires endpoint discovery then the SDK must enable endpoint discovery
// by default for all operations of that service, including operations where endpoint discovery is optional.
optionalDiscoverEndpoint(request);
request.addNamedListener('INVALIDATE_CACHED_ENDPOINTS', 'extractError', invalidateCachedEndpoints);
}
done();
break;

  • The switch case is when isEndpointDiscoveryRequired="OPTIONAL"
  • This happens when operationModel is defined and it's endpointDiscoveryRequired is set to "OPTIONAL"
    var isEndpointDiscoveryRequired = operationModel ? operationModel.endpointDiscoveryRequired : 'NULL';
  • This happens when operation.endpointdiscovery.required value is false or undefined.
    property(
    this,
    'endpointDiscoveryRequired',
    operation.endpointdiscovery ?
    (operation.endpointdiscovery.required ? 'REQUIRED' : 'OPTIONAL') :
    'NULL'
    );
  • The property hasRequiredEndpointDiscovery is not set when operation.endpointdiscovery.required is false or undefined
    if (operation.endpointdiscovery && !self.hasRequiredEndpointDiscovery) {
    property(
    self,
    'hasRequiredEndpointDiscovery',
    operation.endpointdiscovery.required === true
    );
    }

Describe the solution you'd like
Remove redundant hasRequiredEndpointDiscovery check from OPTIONAL switch case for isEndpointDiscoveryRequired.

Additional context
This was noticed while implementing endpoint discovery for AWS SDK for JavaScript (v3) in aws/aws-sdk-js-v3#2211

@github-actions
Copy link

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants