{"record":{"id":"023fdcb784fadc9a","repo":"jackwener/OpenCLI","slug":"error-querying-chatgpt-application-state","errorCode":null,"errorMessage":"Error querying ChatGPT application state","messagePattern":"Error querying ChatGPT application state","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/chatgpt-app/status.js","lineNumber":23,"sourceCode":"    site: 'chatgpt-app',\n    name: 'status',\n    access: 'read',\n    description: 'Check if ChatGPT Desktop App is running natively on macOS',\n    domain: 'localhost',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [],\n    columns: ['Status'],\n    func: async () => {\n        if (process.platform !== 'darwin') {\n            throw new ConfigError('ChatGPT Desktop integration requires macOS (osascript is not available on this platform)');\n        }\n        try {\n            const output = execSync(\"osascript -e 'application \\\"ChatGPT\\\" is running'\", { encoding: 'utf-8' }).trim();\n            return [{ Status: output === 'true' ? 'Running' : 'Stopped' }];\n        }\n        catch {\n            throw new CommandExecutionError('Error querying ChatGPT application state');\n        }\n    },\n});\n","sourceCodeStart":5,"sourceCodeEnd":27,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chatgpt-app/status.js#L5-L27","documentation":"`chatgpt-app status` runs an osascript query for ChatGPT's running state; if that execSync fails (osascript errors, app bundle missing, timeout) it throws this CommandExecutionError, discarding the underlying error detail.","triggerScenarios":"On macOS: osascript returns non-zero because the ChatGPT app is not installed (application not found), Automation permission denied, or the osascript process failed/timed out.","commonSituations":"ChatGPT Desktop uninstalled or renamed; first-time Automation permission prompt denied; running osascript from a context without a GUI session.","solutions":["Verify the ChatGPT Desktop app is installed at /Applications/ChatGPT.app","Grant Automation permission (System Events / ChatGPT) to the calling terminal app","Run the osascript command manually to see the raw error the wrapper hides"],"exampleFix":"// manual diagnosis\nexecSync(\"osascript -e 'application \\\"ChatGPT\\\" is running'\"); // run directly to see stderr\n// or catch and log\ntry { execSync('opencli chatgpt-app status'); } catch (e) { console.error(e.stderr?.toString()); }","handlingStrategy":"try-catch","validationCode":"const installed = fs.existsSync('/Applications/ChatGPT.app');\nif (!installed) throw new Error('ChatGPT Desktop not installed');","typeGuard":null,"tryCatchPattern":"try {\n  const st = execSync('opencli chatgpt-app status').toString().trim();\n} catch (e) {\n  // wrapper hides the cause; run osascript directly to diagnose\n  try {\n    execSync(\"osascript -e 'application \\\"ChatGPT\\\" is running'\", { stdio: 'inherit' });\n  } catch (raw) {\n    console.error('osascript stderr:', raw.stderr?.toString());\n  }\n}","preventionTips":["Verify ChatGPT.app exists in /Applications before status checks","Approve the Automation permission prompt for the calling app the first time","Run status from a GUI user session, not launchd/root contexts without window server access"],"tags":["applescript","desktop-app","process-check"],"backgroundTag":"command-execution-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}