Skip to content

self-auth-linear silently fails to persist workspace tokens when linearWorkspaces is initialized as array #1261

@jakejjoyner

Description

@jakejjoyner

Bug

cyrus self-auth-linear reports "Saved credentials for workspace: X" but the tokens are never actually persisted to config.json. The command exits 0 and looks successful.

Root cause

SelfAuthCommand checks:

if (!config.linearWorkspaces) {
    config.linearWorkspaces = {};
}
config.linearWorkspaces[workspace.id] = { linearToken: ... };
writeFileSync(configPath, JSON.stringify(config, null, "\t"));

When config.json contains \"linearWorkspaces\": [] (an array), !config.linearWorkspaces is false (arrays are truthy), so the initialization to {} is skipped. The assignment arr[uuid] = value sets a named property on the array object, but JSON.stringify silently drops non-numeric properties on arrays. The written file still contains \"linearWorkspaces\": [].

How to reproduce

  1. Create ~/.cyrus/config.json with {\"repositories\": [], \"linearWorkspaces\": []} (array, not object)
  2. Run cyrus self-auth-linear and complete the OAuth flow
  3. Observe "Saved credentials" success message
  4. Check config.jsonlinearWorkspaces is still [], no tokens saved
  5. Run cyrus self-add-repo — fails with "No Linear credentials found"

Fix

Either:

  1. Guard against array input in SelfAuthCommand:

    if (!config.linearWorkspaces || Array.isArray(config.linearWorkspaces)) {
        config.linearWorkspaces = {};
    }
  2. Or enforce object type in migrateEdgeConfig — if linearWorkspaces is an array with no legacy tokens, reset it to {}.

Workaround

Remove the linearWorkspaces key from config.json entirely (or set it to null) before running self-auth-linear. With the key absent, !config.linearWorkspaces is true and it initializes correctly as {}.

Environment

  • cyrus-ai 0.2.57
  • Linux (Arch), Node 26.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions