{"record":{"id":"8d2d71ab4294dc01","repo":"slopus/happy","slug":"no-machine-id-found-in-settings","errorCode":null,"errorMessage":"No machine ID found in settings","messagePattern":"No machine ID found in settings","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/happy-cli/src/agent/acp/runAcp.ts","lineNumber":464,"sourceCode":"  return 'acp';\n}\n\nexport async function runAcp(opts: {\n  credentials: Credentials;\n  agentName: string;\n  command: string;\n  args: string[];\n  startedBy?: 'daemon' | 'terminal';\n  verbose?: boolean;\n}): Promise<void> {\n  const verbose = opts.verbose === true;\n  const sessionTag = randomUUID();\n  connectionState.setBackend(opts.agentName);\n\n  const api = await ApiClient.create(opts.credentials);\n  const settings = await readSettings();\n  if (!settings?.machineId) {\n    throw new Error('No machine ID found in settings');\n  }\n\n  await api.getOrCreateMachine({\n    machineId: settings.machineId,\n    metadata: initialMachineMetadata,\n  });\n\n  const { state, metadata } = createSessionMetadata({\n    flavor: resolveSessionFlavor(opts.agentName),\n    machineId: settings.machineId,\n    startedBy: opts.startedBy,\n    sandbox: settings.sandboxConfig,\n  });\n  const response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });\n  if (response) {\n    logAcp('muted', `Happy Session ID: ${response.id}`);\n  }\n","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/slopus/happy/blob/b824cd0a4681d41af631a8e422a813873e4455b0/packages/happy-cli/src/agent/acp/runAcp.ts#L446-L482","documentation":"runAcp reads the local happy settings file and requires a machineId to register/identify the machine with the happy API (`api.getOrCreateMachine`). If settings are missing or lack machineId, it cannot identify this machine and throws. This is a data prerequisite, not a network failure.","triggerScenarios":"Calling runAcp before ever running `happy` auth/setup that writes settings; a corrupted or reset ~/.happy settings file; settings.json present but machineId key absent (older schema).","commonSituations":"Fresh machine/container where the user never authenticated; CI environments without persisted settings; manually edited or truncated settings file; upgrading from a version that didn't store machineId.","solutions":["Run the happy CLI's normal auth/setup flow once to create settings with machineId.","Inspect the settings file location and confirm a non-empty machineId exists.","Delete the corrupt settings file and re-authenticate to regenerate it.","Ensure HOME/XDG paths are set correctly so readSettings finds the file (CI/containers)."],"exampleFix":"// before\n$ npx happy-cli acp claude-code  // fresh box, no settings\n// after\n$ npx happy-cli auth   # writes settings including machineId\n$ npx happy-cli acp claude-code","handlingStrategy":"validation","validationCode":"import { readSettings } from '...';\nconst settings = await readSettings();\nif (!settings?.machineId) {\n  console.error('Run `happy` auth/setup first to create settings with a machineId');\n  process.exit(1);\n}","typeGuard":"function hasMachineId(s: unknown): s is { machineId: string } & Record<string, unknown> {\n  return typeof s === 'object' && s !== null && 'machineId' in s &&\n    typeof (s as { machineId?: unknown }).machineId === 'string' &&\n    (s as { machineId: string }).machineId.length > 0;\n}","tryCatchPattern":"try {\n  await runAcp(opts);\n} catch (err) {\n  if (err instanceof Error && err.message === 'No machine ID found in settings') {\n    console.error('No happy settings found. Authenticate with the happy CLI first.');\n    process.exit(1);\n  } else throw err;\n}","preventionTips":["Run the happy auth/setup flow before acp/agy on any new machine or container.","Persist settings across CI runs (cache the settings file) instead of starting from zero.","Verify HOME/XDG paths point to the directory holding happy settings.","After upgrading happy, confirm the settings schema still includes machineId."],"tags":["settings","machine-id","configuration","onboarding"],"backgroundTag":"missing-settings-machine-id","analyzedSha":"b824cd0a4681d41af631a8e422a813873e4455b0","analyzedAt":"2026-08-31T23:12:36.205Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}