Skip to content

remove prefix addition to endpoint #3421

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

Merged
merged 2 commits into from
May 16, 2025
Merged

remove prefix addition to endpoint #3421

merged 2 commits into from
May 16, 2025

Conversation

sbera87
Copy link
Contributor

@sbera87 sbera87 commented May 14, 2025

Issue #, if available:

Description of changes:

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sbera87 sbera87 requested a review from sbiscigl May 14, 2025 20:15
Copy link
Contributor

@sbiscigl sbiscigl left a comment

Choose a reason for hiding this comment

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

Think we might want to add a test to the existing s3 control tests so that we test for this and can prevent it from coming back.

@@ -26,9 +26,12 @@ ${indent} }
#if(!$operation.request.shape.hasEventStreamMembers() && !($serviceNamespace == "S3Crt" && $operation.s3CrtEnabled))
${indent} AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ${operation.name}, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage());
#if($operation.hasEndpointTrait)## Note: EndpointDiscovery Trait is not Endpoint Trait
#if($serviceNamespace == "S3Control" && $serviceModel.rawEndpointRules)
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a messy if statement

if($operation.hasEndpointTrait) {
  if ($serviceNamespace == "S3Control" && $serviceModel.rawEndpointRules) {
    // do nothing
  } else {
    addPrefix()
  }
}

something better would be

if(operation.hasEndpointTrait && $serviceNamespace != "S3Control" && !$serviceModel.rawEndpointRules) {
    addPrefix()
}

additionally why not just simply

if(operation.hasEndpointTrait && !$serviceModel.rawEndpointRules) {
    addPrefix()
}

since we will always be providing a endpoint rules set in our default generation path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now will just limit to s3control for the scope of the problem unless really required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The suggestions are not quite right.
The statement right now allows all add prefix for all cases except (s3control && endpoint2.0)
The simplified negation of this is actually !s3control || !endpoint2.0 per De Morgan's law . So i can simplify to that.
https://en.wikipedia.org/wiki/De_Morgan%27s_laws

@sbera87 sbera87 requested a review from sbiscigl May 15, 2025 16:57
@sbera87 sbera87 force-pushed the prefix branch 2 times, most recently from ac2cb11 to c4ff985 Compare May 15, 2025 18:09
.WithBucket(bucket)
.WithAccountId(m_accountId)
.WithBucketAccountId(m_accountId);
auto resolveEndpointOutcome = s3controlClient.accessEndpointProvider()->ResolveEndpoint(request.GetEndpointContextParams());
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesnt actually test the change you made, it tests the endpoint provider, which worked correctly before. You're actually changing client source, so a adequate test would be calling s3controlClient.CreateAccessPoint

@@ -26,9 +26,11 @@ ${indent} }
#if(!$operation.request.shape.hasEventStreamMembers() && !($serviceNamespace == "S3Crt" && $operation.s3CrtEnabled))
${indent} AWS_OPERATION_CHECK_SUCCESS(endpointResolutionOutcome, ${operation.name}, CoreErrors, CoreErrors::ENDPOINT_RESOLUTION_FAILURE, endpointResolutionOutcome.GetError().GetMessage());
#if($operation.hasEndpointTrait)## Note: EndpointDiscovery Trait is not Endpoint Trait
#if(!($serviceNamespace == "S3Control" && $serviceModel.rawEndpointRules))
Copy link
Contributor

Choose a reason for hiding this comment

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

please collapse the if statement to a single if statement, nested if statements should be avoided when possible.

if($operation.hasEndpointTrait && !($serviceNamespace == "S3Control" && $serviceModel.rawEndpointRules))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@sbera87 sbera87 requested a review from sbiscigl May 15, 2025 23:24
const auto requestSeen = mock_http_client->GetMostRecentHttpRequest();
EXPECT_EQ("https://s3express-control.us-east-1.amazonaws.com/v20180820/accesspoint/test-ap--use2-az1--xa-s3", requestSeen.GetUri().GetURIString());

mock_client_factory.reset();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit -- dont need to call reset on a shared_ptr, RAII will do that automatically

@sbera87 sbera87 merged commit 74f407a into main May 16, 2025
3 of 4 checks passed
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.

2 participants