Skip to content
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

chore: remove filterSensitiveLog for service exceptions #488

Merged
merged 3 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ private void renderNonErrorStructure() {
* $fault: "client";
* resourceType: string | undefined;
* }
*
* export namespace NoSuchResource {
* export const filterSensitiveLog = (obj: NoSuchResource): any => ({...obj});
* }
* }</pre>
*/
private void renderErrorStructure() {
Expand All @@ -197,7 +193,6 @@ private void renderErrorStructure() {
structuredMemberWriter.writeMembers(writer, shape);
writer.closeBlock("}"); // interface
writer.write("");
renderStructureNamespace(structuredMemberWriter, false);
}

private void renderStructureNamespace(StructuredMemberWriter structuredMemberWriter, boolean includeValidation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import software.amazon.smithy.model.shapes.StringShape;
import software.amazon.smithy.model.shapes.StructureShape;
import software.amazon.smithy.model.traits.EnumTrait;
import software.amazon.smithy.model.traits.ErrorTrait;
import software.amazon.smithy.model.traits.IdempotencyTokenTrait;
import software.amazon.smithy.model.traits.LengthTrait;
import software.amazon.smithy.model.traits.MediaTypeTrait;
Expand Down Expand Up @@ -163,6 +164,9 @@ private void writeStructureFilterSensitiveLog(
} else if (structureTarget.hasTrait(StreamingTrait.class) && structureTarget.isUnionShape()) {
// disable logging for StreamingTrait
writer.write("'STREAMING_CONTENT'");
} else if (structureTarget.hasTrait(ErrorTrait.class)) {
// Sensitive logs are not filtered from errors.
writer.write("$L", structureParam);
} else {
// Call filterSensitiveLog on Structure.
writer.write("$T.filterSensitiveLog($L)", symbolProvider.toSymbol(structureTarget), structureParam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ private void testErrorStructureCodegen(String file, String expectedType) {
String contents = testStructureCodegen(file, expectedType);

assertThat(contents, containsString("as __SmithyException"));
assertThat(contents, containsString("namespace Err {"));
}

@Test
Expand Down