Skip to content
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

Deprecate url path cleaning during http request serialization #4832

Merged
merged 11 commits into from May 18, 2023

Conversation

wty-Bryant
Copy link
Contributor

@wty-Bryant wty-Bryant commented May 9, 2023

Remove extra path cleaning logic while serializing http request to preserve path fields containing multiple prefix slashes. Solve #4816

Copy link
Contributor

@lucix-aws lucix-aws left a comment

Choose a reason for hiding this comment

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

This is not the right way to do this:

  • You're trying to make service-specific concessions (and keying off of a field name), the protocol serializer should have no notion of these things. Imagine if this were to scale up to special-casing all sorts of different fields, the code would become untenable.
  • This isn't actually escaping the value if it has slashes, it's just hiding it from the path normalization logic and injecting it back after the fact.

We need to start over here. The only change we should need to make is to ensure forward slashes are escaped in values that are present in the request path / query.

@@ -20,7 +20,7 @@ func TestCleanPath(t *testing.T) {
Scheme: "https",
Host: "host",
}
cleanPath(uri)
cleanPath(uri, "")
Copy link
Contributor

@lucix-aws lucix-aws May 9, 2023

Choose a reason for hiding this comment

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

We definitely want a unit test for this behavior (i.e. where the test input has slashes, and we verify they get escaped).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it is incorrect to assume that it is safe to alter topic name by removing prefix forward slashes.

I thought I misunderstood how he wants to escape prefix slashes, I'm investigating it in another way

@wty-Bryant wty-Bryant changed the title Preserve IoT published topic format Deprecate path cleaning during http request serialization May 17, 2023
@wty-Bryant wty-Bryant changed the title Deprecate path cleaning during http request serialization Deprecate url path cleaning during http request serialization May 17, 2023
aws/config.go Outdated
@@ -265,6 +265,8 @@ type Config struct {
// Bucket: aws.String("bucketname"),
// Key: aws.String("//foo//bar//moo"),
// })
// Deprecated: DisableRestProtocolURICleaning exists for historical compatibility of
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this setting is now effectively useless, let's remove everything but the deprecation notice. Let's also reword to clarify the behavior now:
Deprecated: This setting has no longer has any effect. RESTful paths are no longer cleaned after request serialization.

{
"id": "09dc2a79-0637-4b81-8a70-a25a4b238623",
"type": "bugfix",
"description": "remove url path cleaning logic during http request serialization and deprecate its setting",
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use the changelog tool in v1, you have to add an entry to CHANGELOG_PENDING.md.

It should look something like:

* `rest`: Remove unnecessary path normalization behavior.
  * This behavior would incorrectly mutate request paths with URI-encoded characters, potentially resulting in misrouted requests.
* `config`: Deprecate `DisableRestProtocolURICleaning` config setting.
  * This setting no longer has any effect. REST-protocol paths will now never be normalized after serialization.

Copy link
Contributor

Choose a reason for hiding this comment

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

(to the SDK Bugs section)

Copy link
Contributor

@lucix-aws lucix-aws left a comment

Choose a reason for hiding this comment

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

Looks good, some minor housekeeping is in order.

@@ -3,3 +3,7 @@
### SDK Enhancements

### SDK Bugs
* `rest`: Remove unnecessary path normalization behavior.
* This behavior would incorrectly mutate request paths with URI-encoded characters, potentially resulting in misrouted requests.
Copy link
Contributor

Choose a reason for hiding this comment

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

Two spaces here to indent instead of 4. IIRC the code that handles this is incredibly picky, best to be safe.

@@ -497,13 +486,6 @@ func (c *Config) WithLowerCaseHeaderMaps(t bool) *Config {
return c
}

// WithDisableRestProtocolURICleaning sets a config DisableRestProtocolURICleaning value
// returning a Config pointer for chaining.
func (c *Config) WithDisableRestProtocolURICleaning(t bool) *Config {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't remove this (breaking change).

Do please add the same deprecation message as we did on the field itself, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, just over-understand deprecate

Copy link
Contributor

@lucix-aws lucix-aws left a comment

Choose a reason for hiding this comment

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

Approved pending successful CI.

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.

None yet

2 participants