{"record":{"id":"3f1fbe06c6a5377f","repo":"HeyPuter/puter","slug":"internal-error-3f1fbe","errorCode":"internal_error","errorMessage":"No OCR provider configured","messagePattern":"No OCR provider configured","errorType":"http","errorClass":"HttpError","httpStatus":500,"severity":"error","filePath":"src/backend/drivers/ai-ocr/OCRDriver.ts","lineNumber":176,"sourceCode":"\n                this.#mistral = new Mistral({\n                    apiKey: mistral.apiKey,\n                }) as unknown as MistralOcrClient;\n            } catch (e) {\n                console.warn(\n                    '[OCRDriver] Failed to init Mistral:',\n                    (e as Error).message,\n                );\n            }\n        }\n    }\n\n    async recognize(args: RecognizeArgs) {\n        if (args.test_mode) return sampleResponse();\n\n        const provider = this.#resolveProvider(args);\n        if (!provider)\n            throw new HttpError(500, 'No OCR provider configured', {\n                legacyCode: 'internal_error',\n            });\n\n        const actor = Context.get('actor');\n        if (!actor)\n            throw new HttpError(401, 'Authentication required', {\n                legacyCode: 'unauthorized',\n            });\n\n        const input = args.source ?? args.file;\n        if (!input)\n            throw new HttpError(400, '`source` is required', {\n                legacyCode: 'bad_request',\n            });\n\n        const loaded = await loadFileInput(\n            this.stores,\n            this.services.fs,","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/HeyPuter/puter/blob/908ec23eda38526170322c3edf71ba45ecb1ca95/src/backend/drivers/ai-ocr/OCRDriver.ts#L158-L194","documentation":"The OCR driver's #resolveProvider method returned null, meaning no OCR provider could be determined for the request. This happens when: (1) the caller didn't pass an explicit provider, (2) no driver alias was set in the Context, and (3) #defaultProvider() returns null because neither AWS Textract credentials nor a Mistral API key were configured in onServerStart(). This is a server-side configuration failure.","triggerScenarios":"The Puter backend is running without any OCR provider configured in config.json (no aws-textract credentials, no mistral-ocr API key). The first OCR request will hit this error because #defaultProvider() has nothing to fall back to.","commonSituations":"Fresh deployment where OCR providers haven't been configured; config.json was updated but the server wasn't restarted (onServerStart didn't pick up new config); the OCR provider section was accidentally removed from config.","solutions":["Configure at least one OCR provider in config.json under drivers.ai-ocr.providers (either aws-textract with access_key/secret_key, or mistral-ocr with apiKey).","Restart the Puter backend so onServerStart() runs and initializes the provider clients.","Alternatively, pass an explicit provider parameter in the OCR request if a provider is configured but #defaultProvider() can't auto-detect it."],"exampleFix":"// before — config.json with no OCR providers\n\"ai-ocr\": { \"providers\": {} }\n\n// after — add at least one provider\n\"ai-ocr\": {\n  \"providers\": {\n    \"aws-textract\": {\n      \"aws\": {\n        \"access_key\": \"AKIA...\",\n        \"secret_key\": \"...\",\n        \"region\": \"us-west-2\"\n      }\n    }\n  }\n}","handlingStrategy":"try-catch","validationCode":"// Server-side: validate at startup that at least one provider is configured\nfunction validateOcrConfig(config) {\n  const providers = config.drivers?.['ai-ocr']?.providers ?? {};\n  const hasAws = providers['aws-textract']?.aws?.access_key && providers['aws-textract']?.aws?.secret_key;\n  const hasMistral = providers['mistral-ocr']?.apiKey;\n  if (!hasAws && !hasMistral) {\n    throw new Error('At least one OCR provider must be configured');\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await driver.recognize(args);\n} catch (e) {\n  if (e.code === 'internal_error' && e.message === 'No OCR provider configured') {\n    // Server misconfiguration — notify admin, degrade gracefully\n    showAdminAlert('OCR provider not configured');\n  }\n}","preventionTips":["Run a startup validation that at least one OCR provider is configured.","Include OCR provider config in deployment checklists.","Restart the backend after config changes so onServerStart() re-initializes providers."],"tags":["ocr","configuration","provider","server-config","internal-error"],"backgroundTag":null,"analyzedSha":"908ec23eda38526170322c3edf71ba45ecb1ca95","analyzedAt":"2026-08-12T20:53:15.911Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}