Add better invalid service id logs
This commit is contained in:
parent
94c7de6c65
commit
8e59a660ce
1 changed files with 9 additions and 1 deletions
|
@ -53,6 +53,12 @@ export function toUntaggedPni(pni: PniString): UntaggedPniString {
|
||||||
return pni.replace(/^PNI:/i, '') as UntaggedPniString;
|
return pni.replace(/^PNI:/i, '') as UntaggedPniString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const INVALID_SERVICE_ID_PATTERN = /^.*(.{3})/;
|
||||||
|
|
||||||
|
function redactInvalidServiceId(input: string): string {
|
||||||
|
return input.replace(INVALID_SERVICE_ID_PATTERN, '[REDACTED]$1');
|
||||||
|
}
|
||||||
|
|
||||||
export function normalizeServiceId(
|
export function normalizeServiceId(
|
||||||
rawServiceId: string,
|
rawServiceId: string,
|
||||||
context: string,
|
context: string,
|
||||||
|
@ -77,8 +83,10 @@ export function normalizeServiceId(
|
||||||
const result = rawServiceId.toLowerCase().replace(/^pni:/, 'PNI:');
|
const result = rawServiceId.toLowerCase().replace(/^pni:/, 'PNI:');
|
||||||
|
|
||||||
if (!isAciString(result) && !isPniString(result)) {
|
if (!isAciString(result) && !isPniString(result)) {
|
||||||
|
const before = redactInvalidServiceId(rawServiceId);
|
||||||
|
const after = redactInvalidServiceId(result);
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Normalizing invalid serviceId: ${rawServiceId} to ${result} in context "${context}"`
|
`Normalizing invalid serviceId: ${before} to ${after} in context "${context}"`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Cast anyway we don't want to throw here
|
// Cast anyway we don't want to throw here
|
||||||
|
|
Loading…
Reference in a new issue