Skip to content

Commit e00a880

Browse files
committed
Throw error in filterSensitiveLog where the path should never reach
1 parent a75f171 commit e00a880

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Collection;
1919
import java.util.HashSet;
2020
import java.util.Set;
21+
import software.amazon.smithy.codegen.core.CodegenException;
2122
import software.amazon.smithy.codegen.core.SymbolProvider;
2223
import software.amazon.smithy.model.Model;
2324
import software.amazon.smithy.model.shapes.CollectionShape;
@@ -94,9 +95,14 @@ void writeCollectionFilterSensitiveLog(TypeScriptWriter writer, MemberShape coll
9495
}
9596
);
9697
} else {
97-
// This path will never reach because of recursive isIterationRequired.
98-
// Adding it to not break the code, if it does reach in future.
99-
writer.write("item => item");
98+
// This path should not reach because of recursive isIterationRequired.
99+
throw new CodegenException(String.format(
100+
"CollectionFilterSensitiveLog attempted for %s while it was not required",
101+
memberShape.getType()
102+
));
103+
// For quick-fix in case of high severity issue:
104+
// comment out the exception above and uncomment the line below.
105+
// writer.write("item => item");
100106
}
101107
}
102108

@@ -129,9 +135,14 @@ void writeMapFilterSensitiveLog(TypeScriptWriter writer, MemberShape mapMember)
129135
}
130136
);
131137
} else {
132-
// This path will never reach because of recursive isIterationRequired.
133-
// Adding it to not break the code, if it does reach in future.
134-
writer.write("[key]: value,");
138+
// This path should not reach because of recursive isIterationRequired.
139+
throw new CodegenException(String.format(
140+
"MapFilterSensitiveLog attempted for %s while it was not required",
141+
memberShape.getType()
142+
));
143+
// For quick-fix in case of high severity issue:
144+
// comment out the exception above and uncomment the line below.
145+
// writer.write("[key]: value,");
135146
}
136147
}
137148
);

0 commit comments

Comments
 (0)