Skip to content

Commit

Permalink
fix: Correct default zero-value for int enum shapes (#823)
Browse files Browse the repository at this point in the history
* Fix zero-equivalent error correction default value given to int enum member in output that is required but does not have default trait.

* Fix comment on RetryStrategyOptions initializer.

* Change -1 to 0.

---------

Co-authored-by: Sichan Yoo <[email protected]>
  • Loading branch information
sichanyoo and Sichan Yoo committed Sep 13, 2024
1 parent 9115a71 commit 9e614f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/SmithyRetriesAPI/RetryStrategyOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public struct RetryStrategyOptions: Sendable {

/// Creates a new set of retry strategy options
/// - Parameters:
/// - backoffStrategy: Determines the delay time before retrying. Defaults to exponential backoff with a max limit.
/// - backoffStrategy: Determines the delay time before retrying. For default behavior, use `ExponentialBackoffStrategy()`.
/// - maxRetriesBase: The number of times to retry the initial request. Defaults to 2.
/// - availableCapacity: The number of available tokens in a retry quota. Defaults to 500.
/// - maxCapacity: The max number of tokens in a retry quota. Defaults to 500.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ open class MemberShapeDecodeGenerator(
// If member is required but there isn't a default value, use zero-equivalents for error correction
if (requiredTrait != null && defaultTrait == null) {
return when (targetShape) {
is EnumShape, is IntEnumShape -> " ?? .sdkUnknown(\"\")"
is EnumShape -> " ?? .sdkUnknown(\"\")"
is IntEnumShape -> " ?? .sdkUnknown(0)"
is StringShape -> {
// Enum trait is deprecated but many services still use it in their models
if (targetShape.hasTrait<EnumTrait>()) {
Expand Down

0 comments on commit 9e614f2

Please sign in to comment.