Skip to content

Commit

Permalink
Identify specific cases with invalid identity keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-signal committed Jun 6, 2023
1 parent 2b266c7 commit cac0414
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public class Accounts extends AbstractDynamoDbStore {
private static final Timer GET_ALL_FROM_OFFSET_TIMER = Metrics.timer(name(Accounts.class, "getAllFromOffset"));
private static final Timer DELETE_TIMER = Metrics.timer(name(Accounts.class, "delete"));

private static final Counter INVALID_IDENTITY_KEY_COUNTER = Metrics.counter(name(Accounts.class, "invalidIdentityKey"));
private static final Counter INVALID_ACI_IDENTITY_KEY_COUNTER = Metrics.counter(name(Accounts.class, "invalidIdentityKey"), "type", "aci");
private static final Counter INVALID_PNI_IDENTITY_KEY_COUNTER = Metrics.counter(name(Accounts.class, "invalidIdentityKey"), "type", "pni");

private static final String CONDITIONAL_CHECK_FAILED = "ConditionalCheckFailed";

Expand Down Expand Up @@ -918,7 +919,17 @@ static Account fromItem(final Map<String, AttributeValue> item) {
try {
new IdentityKey(account.getIdentityKey());
} catch (final InvalidKeyException e) {
INVALID_IDENTITY_KEY_COUNTER.increment();
log.debug("Account {} has an invalid ACI identity key", account.getUuid());
INVALID_ACI_IDENTITY_KEY_COUNTER.increment();
}
}

if (account.getPhoneNumberIdentityKey() != null && account.getPhoneNumberIdentityKey().length > 0) {
try {
new IdentityKey(account.getPhoneNumberIdentityKey());
} catch (final InvalidKeyException e) {
log.debug("Account {} has an invalid PNI identity key", account.getUuid());
INVALID_PNI_IDENTITY_KEY_COUNTER.increment();
}
}

Expand Down

0 comments on commit cac0414

Please sign in to comment.