Skip to content

fix!: Represent TCP port as UInt16 #1923

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 6 commits into from
Apr 22, 2025
Merged

fix!: Represent TCP port as UInt16 #1923

merged 6 commits into from
Apr 22, 2025

Conversation

jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Apr 22, 2025

Description of changes

[BREAKING] This change breaks public interfaces. SDK minor version is updated to 1.3.0 accordingly.

Changes the type for port number from Int16 to UInt16. TCP port may be from 0-65535 which is beyond the range of Int16.

In this project, this affects the interfaces for the RDS auth token generator. The rest of the changes to port type are in companion PR smithy-lang/smithy-swift#924.

The change is breaking because port number is exposed as a property of several public types and parameters to public functions. The change is being made nonetheless because it is a significant impediment to not allow use of all possible TCP ports.

New/existing dependencies impact assessment, if applicable

No new dependencies were added to this change.

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

@jbelkins jbelkins changed the title fix\!: Represent TCP port as UInt16 fix!: Represent TCP port as UInt16 Apr 22, 2025
@jbelkins jbelkins requested a review from sichanyoo April 22, 2025 16:49
@jbelkins jbelkins assigned dayaffe and unassigned dayaffe Apr 22, 2025
@jbelkins jbelkins requested a review from dayaffe April 22, 2025 16:49
@jbelkins jbelkins marked this pull request as ready for review April 22, 2025 16:49
@@ -66,7 +66,7 @@ class AuthTokenGeneratorIntegration : SwiftIntegration {
/// - expiration: The expiration for the token in seconds. Default is 900 seconds (15 minutes).
public func generateAuthToken(
endpoint: String,
port: Int16,
port: UInt16,
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing Int16 to UInt16 will certainly solve the issue so I am approving, but since this function isnt directly interfacing with C I am of the opinion that this should be Int everywhere in Swift side until the moment it needs to be another type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Found this method while googling around that can potentially take an Int and tell you if its a valid port https://developer.apple.com/documentation/kernel/in_port_t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sticking with UInt16 because it matches exactly the permitted values for TCP port. Using Int would allow customers to specify invalid port values.

I'm aware that Foundation's URLComponents uses Int for port. I don't know their rationale, probably because that is how it bridged over from the original ObjC interface, but I'd prefer to match the TCP allowed values more closely.

@jbelkins jbelkins merged commit 5461273 into main Apr 22, 2025
27 checks passed
@jbelkins jbelkins deleted the jbe/tcp_port_fix branch April 22, 2025 17:24
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.

3 participants