From d4f68b659bf022a5916aedaa8f59e49bc984a349 Mon Sep 17 00:00:00 2001 From: Shirone Date: Sun, 15 Feb 2026 17:46:25 +0100 Subject: [PATCH] fix: address PR #747 review comments - Fix warning box path lines being 2 chars too wide (BOX_CONTENT_WIDTH - 4) - Wrap getClaudeAuthIndicators in try/catch to prevent 500 on auth success - Convert dynamic import to static import for @automaker/platform - Simplify verbose debug logging to log objects directly - Remove unnecessary truthy checks on always-populated path strings Co-Authored-By: Claude Opus 4.6 --- apps/server/src/index.ts | 54 +++---------------- .../routes/setup/routes/verify-claude-auth.ts | 12 ++--- 2 files changed, 14 insertions(+), 52 deletions(-) diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index 3cda977a..4f49d117 100644 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -148,42 +148,10 @@ const BOX_CONTENT_WIDTH = 67; const indicators = cliAuthIndicators; // Log detailed credential detection results - logger.debug('[CREDENTIAL_CHECK] Claude CLI auth indicators:', { - hasCredentialsFile: indicators.hasCredentialsFile, - hasSettingsFile: indicators.hasSettingsFile, - hasStatsCacheWithActivity: indicators.hasStatsCacheWithActivity, - hasProjectsSessions: indicators.hasProjectsSessions, - credentials: indicators.credentials, - }); + const { checks, ...indicatorSummary } = indicators; + logger.debug('[CREDENTIAL_CHECK] Claude CLI auth indicators:', indicatorSummary); - logger.debug('[CREDENTIAL_CHECK] File check details:', { - settingsFile: { - path: indicators.checks.settingsFile.path, - exists: indicators.checks.settingsFile.exists, - readable: indicators.checks.settingsFile.readable, - error: indicators.checks.settingsFile.error, - }, - statsCache: { - path: indicators.checks.statsCache.path, - exists: indicators.checks.statsCache.exists, - readable: indicators.checks.statsCache.readable, - hasDailyActivity: indicators.checks.statsCache.hasDailyActivity, - error: indicators.checks.statsCache.error, - }, - projectsDir: { - path: indicators.checks.projectsDir.path, - exists: indicators.checks.projectsDir.exists, - readable: indicators.checks.projectsDir.readable, - entryCount: indicators.checks.projectsDir.entryCount, - error: indicators.checks.projectsDir.error, - }, - credentialFiles: indicators.checks.credentialFiles.map((cf) => ({ - path: cf.path, - exists: cf.exists, - readable: cf.readable, - error: cf.error, - })), - }); + logger.debug('[CREDENTIAL_CHECK] File check details:', checks); const hasCliAuth = indicators.hasStatsCacheWithActivity || @@ -231,16 +199,10 @@ const BOX_CONTENT_WIDTH = 67; if (cliAuthIndicators) { const pathsChecked: string[] = []; - // Collect paths that were checked - if (cliAuthIndicators.checks.settingsFile.path) { - pathsChecked.push(`Settings: ${cliAuthIndicators.checks.settingsFile.path}`); - } - if (cliAuthIndicators.checks.statsCache.path) { - pathsChecked.push(`Stats cache: ${cliAuthIndicators.checks.statsCache.path}`); - } - if (cliAuthIndicators.checks.projectsDir.path) { - pathsChecked.push(`Projects dir: ${cliAuthIndicators.checks.projectsDir.path}`); - } + // Collect paths that were checked (paths are always populated strings) + pathsChecked.push(`Settings: ${cliAuthIndicators.checks.settingsFile.path}`); + pathsChecked.push(`Stats cache: ${cliAuthIndicators.checks.statsCache.path}`); + pathsChecked.push(`Projects dir: ${cliAuthIndicators.checks.projectsDir.path}`); for (const credFile of cliAuthIndicators.checks.credentialFiles) { pathsChecked.push(`Credentials: ${credFile.path}`); } @@ -249,7 +211,7 @@ const BOX_CONTENT_WIDTH = 67; pathsCheckedInfo = ` ║ ║ ║ ${'Paths checked:'.padEnd(BOX_CONTENT_WIDTH)}║ -${pathsChecked.map((p) => `║ ${p.substring(0, BOX_CONTENT_WIDTH - 2).padEnd(BOX_CONTENT_WIDTH - 2)} ║`).join('\n')}`; +${pathsChecked.map((p) => `║ ${p.substring(0, BOX_CONTENT_WIDTH - 4).padEnd(BOX_CONTENT_WIDTH - 4)} ║`).join('\n')}`; } } diff --git a/apps/server/src/routes/setup/routes/verify-claude-auth.ts b/apps/server/src/routes/setup/routes/verify-claude-auth.ts index 2a8d21b0..405ef9a6 100644 --- a/apps/server/src/routes/setup/routes/verify-claude-auth.ts +++ b/apps/server/src/routes/setup/routes/verify-claude-auth.ts @@ -6,6 +6,7 @@ import type { Request, Response } from 'express'; import { query } from '@anthropic-ai/claude-agent-sdk'; import { createLogger } from '@automaker/utils'; +import { getClaudeAuthIndicators } from '@automaker/platform'; import { getApiKey } from '../common.js'; import { createSecureAuthEnv, @@ -327,12 +328,11 @@ export function createVerifyClaudeAuthHandler() { authType = 'api_key'; } else if (authMethod === 'cli') { // Check if CLI auth is via OAuth (Claude Code subscription) or generic CLI - // OAuth tokens are stored in the credentials file by the Claude CLI - const { getClaudeAuthIndicators } = await import('@automaker/platform'); - const indicators = await getClaudeAuthIndicators(); - if (indicators.credentials?.hasOAuthToken) { - authType = 'oauth'; - } else { + try { + const indicators = await getClaudeAuthIndicators(); + authType = indicators.credentials?.hasOAuthToken ? 'oauth' : 'cli'; + } catch { + // Fall back to generic CLI if credential check fails authType = 'cli'; } }