Skip to content

bug: parseSettings missing discordUserIds parameter causes ReferenceError on startup #63

@bladewing

Description

@bladewing

Bug Description

parseSettings() in src/config.ts (line 220) is missing the discordUserIds parameter from its signature, but:

  1. Both callers (loadSettings at line ~340 and reloadSettings at line ~348) pass a second argument: parseSettings(raw, extractDiscordUserIds(rawText))
  2. The function body (line ~252) references discordUserIds to populate discord.allowedUserIds

This causes a ReferenceError: discordUserIds is not defined crash on daemon startup.

ReferenceError: discordUserIds is not defined
      at parseSettings (src/config.ts:252:23)
      at loadSettings (src/config.ts:340:12)

Root Cause

An incomplete refactoring in commit 58f6c4f removed discordUserIds from the function signature but left the body and callers unchanged.

Why This Matters

Discord snowflake IDs exceed Number.MAX_SAFE_INTEGER (2^53 - 1). The extractDiscordUserIds() function exists specifically to extract these IDs as raw strings from the JSON text before JSON.parse loses precision. Without this parameter, Discord authentication silently breaks even if the crash is worked around.

Fix

One-line change — add the parameter back to the signature:

-function parseSettings(raw: Record<string, any>): Settings {
+function parseSettings(raw: Record<string, any>, discordUserIds?: string[]): Settings {

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions