{"record":{"id":"a26c21a0b34e5e68","repo":"coleam00/Archon","slug":"could-not-read-your-per-user-prefs-showing-inst","errorCode":null,"errorMessage":"(could not read your per-user prefs — showing install config only)","messagePattern":"\\(could not read your per-user prefs — showing install config only\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/cli/src/commands/ai.ts","lineNumber":459,"sourceCode":"    getLog().error({ err: err as Error, tier, scope: resolvedScope }, 'cli.ai_tier_unset_failed');\n    console.error(`✗ ${(err as Error).message}`);\n    return 1;\n  }\n}\n\n/**\n * Best-effort read of the CLI user's prefs for listings — `{}` when no CLI\n * identity resolves or the DB read fails (solo installs just see config).\n */\nasync function readUserPrefsBestEffort(): Promise<UserAiPrefs> {\n  const cliId = resolveCliUserId();\n  if (!cliId) return {};\n  try {\n    const user = await userDb.findOrCreateUserByPlatformIdentity('cli', cliId, cliId);\n    return await getUserAiPrefs(user.id);\n  } catch (err) {\n    getLog().warn({ err: err as Error }, 'cli.ai_user_prefs_read_failed');\n    // Visible notice so the listing isn't mistaken for \"you have no overrides\".\n    console.error('(could not read your per-user prefs — showing install config only)');\n    return {};\n  }\n}\n\n/** `archon ai tier list [--json]` — show install + per-user scopes and the effective value. */\nexport async function aiTierListCommand(json?: boolean): Promise<number> {\n  try {\n    const config = await loadConfig();\n    const configured = config.tiers ?? {};\n    const userPrefs = await readUserPrefsBestEffort();\n    const userTiers = userPrefs.tiers ?? {};\n    const effectiveAssistant = userPrefs.defaultProvider ?? config.assistant;\n    // No options → just the built-in tier-defaults for the default provider.\n    // Degrade like the route's `tierDefaultsFor` (buildAiProfile ~never throws\n    // with no aliases, but a defaults lookup must not fail the whole listing).\n    let defaults: Record<string, RawAliasEntry> = {};\n    try {","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/ai.ts#L441-L477","documentation":"readUserPrefsBestEffort prints this notice to stderr when reading the CLI user's AI preferences from the database fails. It is an intentional best-effort fallback: the command continues with install-level config only, and the notice prevents the user from mistaking the listing for 'you have no per-user overrides'.","triggerScenarios":"Running an `archon ai` command (e.g. `archon ai tier list`) while getUserAiPrefs or findOrCreateUserByPlatformIdentity('cli', cliId, cliId) throws — no CLI identity configured, DB unavailable/corrupt, or schema/migration mismatch.","commonSituations":"Fresh install with no `archon` CLI identity yet; server DB unreachable; developer pointing the CLI at a different environment than the server.","solutions":["Check the logged warn event 'cli.ai_user_prefs_read_failed' for the underlying error (DB connection, missing table, identity failure)","Verify the CLI is configured and can reach the server (`archon` setup / connection settings)","Run any pending server migrations so user/prefs tables exist and match the binary","Re-run the command once the DB is reachable; per-user prefs will be included again"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// best-effort read with explicit notice\nlet prefs = {};\ntry { prefs = await readUserPrefsBestEffort(cliId); }\ncatch { console.error('(could not read your per-user prefs — showing install config only)'); }","typeGuard":null,"tryCatchPattern":"try {\n  prefs = await getUserAiPrefs(user.id);\n} catch (err) {\n  getLog().warn({ err }, 'cli.ai_user_prefs_read_failed');\n  prefs = {}; // install config only\n}","preventionTips":["Ensure CLI identity is configured before running `archon ai` commands","Keep server and CLI versions in sync so prefs tables exist","Monitor the 'cli.ai_user_prefs_read_failed' warn event","Treat empty prefs output as suspect when the DB is known to be flaky"],"tags":["cli","database","best-effort-fallback","user-prefs"],"backgroundTag":"prefs-read-fallback","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}