Skip to content

Commit e83e9b3

Browse files
authored
chore: remove filterSensitiveLog for service exceptions (#488)
1 parent 000909d commit e83e9b3

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructureGenerator.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ private void renderNonErrorStructure() {
168168
* $fault: "client";
169169
* resourceType: string | undefined;
170170
* }
171-
*
172-
* export namespace NoSuchResource {
173-
* export const filterSensitiveLog = (obj: NoSuchResource): any => ({...obj});
174-
* }
175171
* }</pre>
176172
*/
177173
private void renderErrorStructure() {
@@ -197,7 +193,6 @@ private void renderErrorStructure() {
197193
structuredMemberWriter.writeMembers(writer, shape);
198194
writer.closeBlock("}"); // interface
199195
writer.write("");
200-
renderStructureNamespace(structuredMemberWriter, false);
201196
}
202197

203198
private void renderStructureNamespace(StructuredMemberWriter structuredMemberWriter, boolean includeValidation) {

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/StructuredMemberWriter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import software.amazon.smithy.model.shapes.StringShape;
3535
import software.amazon.smithy.model.shapes.StructureShape;
3636
import software.amazon.smithy.model.traits.EnumTrait;
37+
import software.amazon.smithy.model.traits.ErrorTrait;
3738
import software.amazon.smithy.model.traits.IdempotencyTokenTrait;
3839
import software.amazon.smithy.model.traits.LengthTrait;
3940
import software.amazon.smithy.model.traits.MediaTypeTrait;
@@ -163,6 +164,9 @@ private void writeStructureFilterSensitiveLog(
163164
} else if (structureTarget.hasTrait(StreamingTrait.class) && structureTarget.isUnionShape()) {
164165
// disable logging for StreamingTrait
165166
writer.write("'STREAMING_CONTENT'");
167+
} else if (structureTarget.hasTrait(ErrorTrait.class)) {
168+
// Sensitive logs are not filtered from errors.
169+
writer.write("$L", structureParam);
166170
} else {
167171
// Call filterSensitiveLog on Structure.
168172
writer.write("$T.filterSensitiveLog($L)", symbolProvider.toSymbol(structureTarget), structureParam);

smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/StructureGeneratorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ private void testErrorStructureCodegen(String file, String expectedType) {
481481
String contents = testStructureCodegen(file, expectedType);
482482

483483
assertThat(contents, containsString("as __SmithyException"));
484-
assertThat(contents, containsString("namespace Err {"));
485484
}
486485

487486
@Test

0 commit comments

Comments
 (0)