fix: revert remaining ?? '' patterns across Utils, WABinary, Signal, and WAUSync files

Completes the comprehensive revert of defensive null coalescing patterns
introduced in PRs 124-129. These patterns (e.g. `value ?? ''`) silently
produced empty strings instead of failing fast, causing subtle bugs like
malformed JIDs and broken Signal session lookups.

Files: libsignal.ts, messages-recv.ts, chat-utils.ts, generics.ts,
history.ts, messages-media.ts, messages.ts, process-message.ts,
validate-connection.ts, jid-utils.ts, UsyncBotProfileProtocol.ts

https://claude.ai/code/session_01XaA7GwNaB6azTHFYQ8WEpB
This commit is contained in:
Claude
2026-02-09 13:56:33 +00:00
parent 48b63565b6
commit 2a9d9a0a52
11 changed files with 61 additions and 64 deletions
@@ -35,7 +35,7 @@ export class USyncBotProfileProtocol implements USyncQueryProtocol {
return {
tag: 'bot',
attrs: {},
content: [{ tag: 'profile', attrs: { persona_id: user.personaId ?? '' } }]
content: [{ tag: 'profile', attrs: { persona_id: user.personaId! } }]
}
}
@@ -51,24 +51,24 @@ export class USyncBotProfileProtocol implements USyncQueryProtocol {
for (const command of getBinaryNodeChildren(commandsNode, 'command')) {
commands.push({
name: getBinaryNodeChildString(command, 'name') ?? '',
description: getBinaryNodeChildString(command, 'description') ?? ''
name: getBinaryNodeChildString(command, 'name')!,
description: getBinaryNodeChildString(command, 'description')!
})
}
for (const prompt of getBinaryNodeChildren(promptsNode, 'prompt')) {
prompts.push(`${getBinaryNodeChildString(prompt, 'emoji') ?? ''} ${getBinaryNodeChildString(prompt, 'text') ?? ''}`)
prompts.push(`${getBinaryNodeChildString(prompt, 'emoji')!} ${getBinaryNodeChildString(prompt, 'text')!}`)
}
return {
isDefault: !!getBinaryNodeChild(profile, 'default'),
jid: node.attrs.jid ?? '',
name: getBinaryNodeChildString(profile, 'name') ?? '',
attributes: getBinaryNodeChildString(profile, 'attributes') ?? '',
description: getBinaryNodeChildString(profile, 'description') ?? '',
category: getBinaryNodeChildString(profile, 'category') ?? '',
personaId: profile?.attrs['persona_id'] ?? '',
commandsDescription: getBinaryNodeChildString(commandsNode, 'description') ?? '',
jid: node.attrs.jid!,
name: getBinaryNodeChildString(profile, 'name')!,
attributes: getBinaryNodeChildString(profile, 'attributes')!,
description: getBinaryNodeChildString(profile, 'description')!,
category: getBinaryNodeChildString(profile, 'category')!,
personaId: profile!.attrs['persona_id']!,
commandsDescription: getBinaryNodeChildString(commandsNode, 'description')!,
commands,
prompts
}