From d72c59e79a1c86a4c3750a0daec11344c18284f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Mon, 21 Jul 2025 08:03:10 +0200 Subject: [PATCH 1/4] hard code version number in user agent string --- Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift b/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift index 5848ec76..b923079d 100644 --- a/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift +++ b/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift @@ -93,7 +93,7 @@ struct ControlPlaneRequestEncoder: _EmittingChannelHandler { extension String { static let CRLF: String = "\r\n" - static let userAgent = "Swift-Lambda/Unknown" + static let userAgent = "Swift-Lambda/2.0" static let userAgentHeader: String = "user-agent: \(userAgent)\r\n" static let unhandledErrorHeader: String = "lambda-runtime-function-error-type: Unhandled\r\n" From 79254a27f03c752981d9beb36b9daada9b9c536a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Mon, 21 Jul 2025 08:06:31 +0200 Subject: [PATCH 2/4] externalize version number --- .../ControlPlaneRequestEncoder.swift | 2 +- Sources/AWSLambdaRuntime/Version.swift | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Sources/AWSLambdaRuntime/Version.swift diff --git a/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift b/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift index b923079d..84f0cf0e 100644 --- a/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift +++ b/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift @@ -93,7 +93,7 @@ struct ControlPlaneRequestEncoder: _EmittingChannelHandler { extension String { static let CRLF: String = "\r\n" - static let userAgent = "Swift-Lambda/2.0" + static let userAgent = "Swift-Lambda/\(Version.current)" static let userAgentHeader: String = "user-agent: \(userAgent)\r\n" static let unhandledErrorHeader: String = "lambda-runtime-function-error-type: Unhandled\r\n" diff --git a/Sources/AWSLambdaRuntime/Version.swift b/Sources/AWSLambdaRuntime/Version.swift new file mode 100644 index 00000000..a2157c54 --- /dev/null +++ b/Sources/AWSLambdaRuntime/Version.swift @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftAWSLambdaRuntime open source project +// +// Copyright (c) 2017-2018 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +/// Library version of the AWS Lambda Runtime. +/// This is used in the User Agent header when making requests to the AWS Lambda data Plane. +package enum Version { + /// The current version of the AWS Lambda Runtime. + public static let current = "2.0" +} \ No newline at end of file From f14426bf2f41696ee0056df1a2e2abbc0892d5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Mon, 21 Jul 2025 08:24:24 +0200 Subject: [PATCH 3/4] add comments --- Sources/AWSLambdaRuntime/Version.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Sources/AWSLambdaRuntime/Version.swift b/Sources/AWSLambdaRuntime/Version.swift index a2157c54..106b416b 100644 --- a/Sources/AWSLambdaRuntime/Version.swift +++ b/Sources/AWSLambdaRuntime/Version.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// -/// Library version of the AWS Lambda Runtime. -/// This is used in the User Agent header when making requests to the AWS Lambda data Plane. + /// The version of the AWS Lambda Runtime. + /// + /// This is used in the User Agent header when making requests to the AWS Lambda data Plane. + /// + /// - Note: This is a static property that returns the current version of the AWS Lambda Runtime. + /// It is used to ensure that the runtime can be identified by the AWS Lambda service. + /// As such, we mainly care about major version and minor version. Patch and pre-release versions are ignored. package enum Version { /// The current version of the AWS Lambda Runtime. - public static let current = "2.0" + package static let current = "2.0" } \ No newline at end of file From 28bc5ff6bdc60a01e31a7d5e658f371c92c3736f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Mon, 21 Jul 2025 08:24:50 +0200 Subject: [PATCH 4/4] swift-format --- Sources/AWSLambdaRuntime/Version.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/AWSLambdaRuntime/Version.swift b/Sources/AWSLambdaRuntime/Version.swift index 106b416b..f55c30f1 100644 --- a/Sources/AWSLambdaRuntime/Version.swift +++ b/Sources/AWSLambdaRuntime/Version.swift @@ -12,14 +12,14 @@ // //===----------------------------------------------------------------------===// - /// The version of the AWS Lambda Runtime. - /// - /// This is used in the User Agent header when making requests to the AWS Lambda data Plane. - /// - /// - Note: This is a static property that returns the current version of the AWS Lambda Runtime. - /// It is used to ensure that the runtime can be identified by the AWS Lambda service. - /// As such, we mainly care about major version and minor version. Patch and pre-release versions are ignored. +/// The version of the AWS Lambda Runtime. +/// +/// This is used in the User Agent header when making requests to the AWS Lambda data Plane. +/// +/// - Note: This is a static property that returns the current version of the AWS Lambda Runtime. +/// It is used to ensure that the runtime can be identified by the AWS Lambda service. +/// As such, we mainly care about major version and minor version. Patch and pre-release versions are ignored. package enum Version { - /// The current version of the AWS Lambda Runtime. - package static let current = "2.0" -} \ No newline at end of file + /// The current version of the AWS Lambda Runtime. + package static let current = "2.0" +}