Skip to content

Commit a59f99a

Browse files
committed
refactor: protect against null, remove nullish coalescing
1 parent f60dd0a commit a59f99a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

backend/src/services/weekly-xp-leaderboard.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,14 @@ export class WeeklyXpLeaderboard {
221221
[null, string | null]
222222
];
223223

224-
if (rank === null) {
224+
if (rank === null || result === null) {
225225
return null;
226226
}
227227

228228
// safely parse the result with error handling
229229
let parsed: RedisXpLeaderboardEntry;
230230
try {
231-
parsed = parseJsonWithSchema(
232-
result ?? "null",
233-
RedisXpLeaderboardEntrySchema
234-
);
231+
parsed = parseJsonWithSchema(result, RedisXpLeaderboardEntrySchema);
235232
} catch (error) {
236233
throw new MonkeyError(
237234
500,

0 commit comments

Comments
 (0)