Skip to content

Commit 139f903

Browse files
authored
chore: repolymorph to revert opaque string (#929)
* chore: repolymorph to revert opaque string
1 parent a952fc3 commit 139f903

File tree

44 files changed

+83
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+83
-365
lines changed

AwsCryptographicMaterialProviders/dafny/AwsCryptographicMaterialProviders/Model/AwsCryptographyMaterialProvidersTypes.dfy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ module {:extern "software.amazon.cryptography.materialproviders.internaldafny.ty
17121712
// || (!exit(A(I)) && !access(B(I)))
17131713
| CollectionOfErrors(list: seq<Error>, nameonly message: string)
17141714
// The Opaque error, used for native, extern, wrapped or unknown errors
1715-
| Opaque(obj: object, alt_text : string := "")
1715+
| Opaque(obj: object)
17161716
type OpaqueError = e: Error | e.Opaque? witness *
17171717
}
17181718
abstract module AbstractAwsCryptographyMaterialProvidersService

AwsCryptographicMaterialProviders/dafny/AwsCryptographyKeyStore/Model/AwsCryptographyKeyStoreTypes.dfy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ module {:extern "software.amazon.cryptography.keystore.internaldafny.types" } Aw
282282
// || (!exit(A(I)) && !access(B(I)))
283283
| CollectionOfErrors(list: seq<Error>, nameonly message: string)
284284
// The Opaque error, used for native, extern, wrapped or unknown errors
285-
| Opaque(obj: object, alt_text : string := "")
285+
| Opaque(obj: object)
286286
type OpaqueError = e: Error | e.Opaque? witness *
287287
}
288288
abstract module AbstractAwsCryptographyKeyStoreService

AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/ToDafny.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,11 @@ public static Error Error(RuntimeException nativeValue) {
5656
if (nativeValue instanceof CollectionOfErrors) {
5757
return ToDafny.Error((CollectionOfErrors) nativeValue);
5858
}
59-
return Error.create_Opaque(
60-
nativeValue,
61-
dafny.DafnySequence.asString(
62-
java.util.Objects.nonNull(nativeValue.getMessage())
63-
? nativeValue.getMessage()
64-
: ""
65-
)
66-
);
59+
return Error.create_Opaque(nativeValue);
6760
}
6861

6962
public static Error Error(OpaqueError nativeValue) {
70-
return Error.create_Opaque(
71-
nativeValue.obj(),
72-
dafny.DafnySequence.asString(
73-
java.util.Objects.nonNull(nativeValue.altText())
74-
? nativeValue.altText()
75-
: ""
76-
)
77-
);
63+
return Error.create_Opaque(nativeValue.obj());
7864
}
7965

8066
public static Error Error(CollectionOfErrors nativeValue) {

AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/keystore/model/OpaqueError.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ public class OpaqueError extends RuntimeException {
1010
*/
1111
private final Object obj;
1212

13-
/**
14-
* A best effort text representation of obj.
15-
*/
16-
private final String altText;
17-
1813
protected OpaqueError(BuilderImpl builder) {
1914
super(messageFromBuilder(builder), builder.cause());
20-
this.altText = builder.altText();
2115
this.obj = builder.obj();
2216
}
2317

@@ -52,13 +46,6 @@ public Object obj() {
5246
return this.obj;
5347
}
5448

55-
/**
56-
* @return A best effort text representation of obj.
57-
*/
58-
public String altText() {
59-
return this.altText;
60-
}
61-
6249
public Builder toBuilder() {
6350
return new BuilderImpl(this);
6451
}
@@ -98,16 +85,6 @@ public interface Builder {
9885
*/
9986
Object obj();
10087

101-
/**
102-
* @param altText A best effort text representation of obj.
103-
*/
104-
Builder altText(String altText);
105-
106-
/**
107-
* @return A best effort text representation of obj.
108-
*/
109-
String altText();
110-
11188
OpaqueError build();
11289
}
11390

@@ -119,8 +96,6 @@ static class BuilderImpl implements Builder {
11996

12097
protected Object obj;
12198

122-
protected String altText;
123-
12499
protected BuilderImpl() {}
125100

126101
protected BuilderImpl(OpaqueError model) {
@@ -156,15 +131,6 @@ public Object obj() {
156131
return this.obj;
157132
}
158133

159-
public Builder altText(String altText) {
160-
this.altText = altText;
161-
return this;
162-
}
163-
164-
public String altText() {
165-
return this.altText;
166-
}
167-
168134
public OpaqueError build() {
169135
if (
170136
this.obj != null && this.cause == null && this.obj instanceof Throwable

AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/materialproviders/ToDafny.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,25 +173,11 @@ public static Error Error(RuntimeException nativeValue) {
173173
if (nativeValue instanceof CollectionOfErrors) {
174174
return ToDafny.Error((CollectionOfErrors) nativeValue);
175175
}
176-
return Error.create_Opaque(
177-
nativeValue,
178-
dafny.DafnySequence.asString(
179-
java.util.Objects.nonNull(nativeValue.getMessage())
180-
? nativeValue.getMessage()
181-
: ""
182-
)
183-
);
176+
return Error.create_Opaque(nativeValue);
184177
}
185178

186179
public static Error Error(OpaqueError nativeValue) {
187-
return Error.create_Opaque(
188-
nativeValue.obj(),
189-
dafny.DafnySequence.asString(
190-
java.util.Objects.nonNull(nativeValue.altText())
191-
? nativeValue.altText()
192-
: ""
193-
)
194-
);
180+
return Error.create_Opaque(nativeValue.obj());
195181
}
196182

197183
public static Error Error(CollectionOfErrors nativeValue) {

AwsCryptographicMaterialProviders/runtimes/java/src/main/smithy-generated/software/amazon/cryptography/materialproviders/model/OpaqueError.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ public class OpaqueError extends RuntimeException {
1010
*/
1111
private final Object obj;
1212

13-
/**
14-
* A best effort text representation of obj.
15-
*/
16-
private final String altText;
17-
1813
protected OpaqueError(BuilderImpl builder) {
1914
super(messageFromBuilder(builder), builder.cause());
20-
this.altText = builder.altText();
2115
this.obj = builder.obj();
2216
}
2317

@@ -52,13 +46,6 @@ public Object obj() {
5246
return this.obj;
5347
}
5448

55-
/**
56-
* @return A best effort text representation of obj.
57-
*/
58-
public String altText() {
59-
return this.altText;
60-
}
61-
6249
public Builder toBuilder() {
6350
return new BuilderImpl(this);
6451
}
@@ -98,16 +85,6 @@ public interface Builder {
9885
*/
9986
Object obj();
10087

101-
/**
102-
* @param altText A best effort text representation of obj.
103-
*/
104-
Builder altText(String altText);
105-
106-
/**
107-
* @return A best effort text representation of obj.
108-
*/
109-
String altText();
110-
11188
OpaqueError build();
11289
}
11390

@@ -119,8 +96,6 @@ static class BuilderImpl implements Builder {
11996

12097
protected Object obj;
12198

122-
protected String altText;
123-
12499
protected BuilderImpl() {}
125100

126101
protected BuilderImpl(OpaqueError model) {
@@ -156,15 +131,6 @@ public Object obj() {
156131
return this.obj;
157132
}
158133

159-
public Builder altText(String altText) {
160-
this.altText = altText;
161-
return this;
162-
}
163-
164-
public String altText() {
165-
return this.altText;
166-
}
167-
168134
public OpaqueError build() {
169135
if (
170136
this.obj != null && this.cause == null && this.obj instanceof Throwable

AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographicMaterialProviders/TypeConversion.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,12 +3976,12 @@ public static software.amazon.cryptography.materialproviders.internaldafny.types
39763976
);
39773977
// OpaqueError is redundant, but listed for completeness.
39783978
case OpaqueError exception:
3979-
return new software.amazon.cryptography.materialproviders.internaldafny.types.Error_Opaque(exception, Dafny.Sequence<char>.FromString(exception.ToString()));
3979+
return new software.amazon.cryptography.materialproviders.internaldafny.types.Error_Opaque(exception);
39803980
case System.Exception exception:
3981-
return new software.amazon.cryptography.materialproviders.internaldafny.types.Error_Opaque(exception, Dafny.Sequence<char>.FromString(exception.ToString()));
3981+
return new software.amazon.cryptography.materialproviders.internaldafny.types.Error_Opaque(exception);
39823982
default:
39833983
// The switch MUST be complete for System.Exception, so `value` MUST NOT be an System.Exception. (How did you get here?)
3984-
return new software.amazon.cryptography.materialproviders.internaldafny.types.Error_Opaque(value, Dafny.Sequence<char>.FromString(value.ToString()));
3984+
return new software.amazon.cryptography.materialproviders.internaldafny.types.Error_Opaque(value);
39853985
}
39863986
}
39873987
}

AwsCryptographicMaterialProviders/runtimes/net/Generated/AwsCryptographyKeyStore/TypeConversion.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,12 +785,12 @@ public static software.amazon.cryptography.keystore.internaldafny.types._IError
785785
);
786786
// OpaqueError is redundant, but listed for completeness.
787787
case OpaqueError exception:
788-
return new software.amazon.cryptography.keystore.internaldafny.types.Error_Opaque(exception, Dafny.Sequence<char>.FromString(exception.ToString()));
788+
return new software.amazon.cryptography.keystore.internaldafny.types.Error_Opaque(exception);
789789
case System.Exception exception:
790-
return new software.amazon.cryptography.keystore.internaldafny.types.Error_Opaque(exception, Dafny.Sequence<char>.FromString(exception.ToString()));
790+
return new software.amazon.cryptography.keystore.internaldafny.types.Error_Opaque(exception);
791791
default:
792792
// The switch MUST be complete for System.Exception, so `value` MUST NOT be an System.Exception. (How did you get here?)
793-
return new software.amazon.cryptography.keystore.internaldafny.types.Error_Opaque(value, Dafny.Sequence<char>.FromString(value.ToString()));
793+
return new software.amazon.cryptography.keystore.internaldafny.types.Error_Opaque(value);
794794
}
795795
}
796796
}

AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/deserialize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _deserialize_get_beacon_key(input: DafnyResponse, config: Config):
102102

103103
def _deserialize_error(error: Error) -> ServiceError:
104104
if error.is_Opaque:
105-
return OpaqueError(obj=error.obj, alt_text=error.alt__text)
105+
return OpaqueError(obj=error.obj)
106106
elif error.is_CollectionOfErrors:
107107
return CollectionOfErrors(
108108
message=_dafny.string_of(error.message),
@@ -117,4 +117,4 @@ def _deserialize_error(error: Error) -> ServiceError:
117117
message=_dafny.string_of(error.ComAmazonawsDynamodb.message)
118118
)
119119
else:
120-
return OpaqueError(obj=error, alt_text=repr(error))
120+
return OpaqueError(obj=error)

AwsCryptographicMaterialProviders/runtimes/python/src/aws_cryptographic_material_providers/smithygenerated/aws_cryptography_keystore/errors.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,9 @@ class OpaqueError(ApiError[Literal["OpaqueError"]]):
152152
code: Literal["OpaqueError"] = "OpaqueError"
153153
obj: Any # As an OpaqueError, type of obj is unknown
154154

155-
def __init__(self, *, obj, alt_text):
155+
def __init__(self, *, obj):
156156
super().__init__("")
157157
self.obj = obj
158-
self.alt_text = alt_text
159158

160159
def as_dict(self) -> Dict[str, Any]:
161160
"""Converts the OpaqueError to a dictionary.
@@ -167,7 +166,6 @@ def as_dict(self) -> Dict[str, Any]:
167166
"message": self.message,
168167
"code": self.code,
169168
"obj": self.obj,
170-
"alt_text": self.alt_text,
171169
}
172170

173171
@staticmethod
@@ -178,11 +176,7 @@ def from_dict(d: Dict[str, Any]) -> "OpaqueError":
178176
than the parameter names as keys to be mostly compatible with
179177
boto3.
180178
"""
181-
kwargs: Dict[str, Any] = {
182-
"message": d["message"],
183-
"obj": d["obj"],
184-
"alt_text": d["alt_text"],
185-
}
179+
kwargs: Dict[str, Any] = {"message": d["message"], "obj": d["obj"]}
186180

187181
return OpaqueError(**kwargs)
188182

@@ -191,7 +185,7 @@ def __repr__(self) -> str:
191185
result += f"message={self.message},"
192186
if self.message is not None:
193187
result += f"message={repr(self.message)}"
194-
result += f"obj={self.alt_text}"
188+
result += f"obj={self.obj}"
195189
result += ")"
196190
return result
197191

@@ -235,18 +229,10 @@ def _smithy_error_to_dafny_error(e: ServiceError):
235229

236230
if isinstance(e, OpaqueError):
237231
return aws_cryptographic_material_providers.internaldafny.generated.AwsCryptographyKeyStoreTypes.Error_Opaque(
238-
obj=e.obj, alt__text=e.alt_text
232+
obj=e.obj
239233
)
240234

241235
else:
242236
return aws_cryptographic_material_providers.internaldafny.generated.AwsCryptographyKeyStoreTypes.Error_Opaque(
243-
obj=e,
244-
alt__text=_dafny.Seq(
245-
"".join(
246-
[
247-
chr(int.from_bytes(pair, "big"))
248-
for pair in zip(*[iter(repr(e).encode("utf-16-be"))] * 2)
249-
]
250-
)
251-
),
237+
obj=e
252238
)

0 commit comments

Comments
 (0)