LegalEntitySaga fails internally if any of the usernames being processed contains the character `%`
pssm opened this issue · 1 comments
A Saga will fail internally if the username contains a %
character while executing the below call (com.backbase.stream.LegalEntitySaga#upsertIdentityUser
):
private Mono<User> upsertIdentityUser(LegalEntityTask streamTask, User user) {
streamTask.info(IDENTITY_USER, UPSERT, "", user.getExternalId(), "Upsert User to Identity with External ID: %s", user.getExternalId());
Since no messageArgs
arguments are passed to the info
method, the String.format(... , ...)
is effectively called with a message
that semantically contains a pattern format (e.g. %s
if the username is Test%simple
), but with no messageArgs
, causing, in this particular example, a MissingFormatArgumentException
.
public void info(String entity, String operation, String result, String externalId, String internalId,
String message, Object... messageArgs) {
addHistory(entity, operation, result, externalId, internalId, String.format(message, messageArgs),
TaskHistory.Severity.INFO, null, null);
}
Other variants of the same error also happen if other invalid pattern symbols happen to be present in the username, like %e
(e.g. Test%error
):
10:09:56.266] [reactor-http-nio-2] [ERROR] [reactor.core.publisher.Operators] Operator called default onErrorDropped
java.util.UnknownFormatConversionException: Conversion = '%'
at java.base/java.util.Formatter.checkText(Formatter.java:2732)
at java.base/java.util.Formatter.parse(Formatter.java:2718)
at java.base/java.util.Formatter.format(Formatter.java:2655)
at java.base/java.util.Formatter.format(Formatter.java:2609)
at java.base/java.lang.String.format(String.java:2897)
at com.backbase.stream.worker.model.StreamTask.info(StreamTask.java:35)
As a major consequence, the Saga will stop - incorrectly - the Legal Entity ingestion.
The below snippets trigger the same kind of error described above.
class Scratch {
public static void main(String[] args) {
String.format("Test%simple", new Object[0]);
}
}
class Scratch {
public static void main(String[] args) {
String.format("Test%e", new Object[0]);
}
}
Disregarding the above error, the streamTask.info(IDENTITY_USER, UPSERT, "", user.getExternalId(), "Upsert User to Identity with External ID: %s", user.getExternalId());
has the arguments in incorrect order.
info(String entity, String operation, String result, String externalId, String internalId,
String message, Object... messageArgs) {
IDENTITY_USER
->entity
UPSERT
->operation
""
->result
(wrong)user.getExternalId()
->externalID
"Upsert User to Identity with External ID: %s"
->internalID
(wrong)user.getExternalId()
->message
(wrong)null
->messageArgs