{"record":{"id":"a3e0f0c4f2b9c27b","repo":"siyuan-note/siyuan","slug":"langs-lang-266","errorCode":null,"errorMessage":"Langs[Lang][266]","messagePattern":"Langs\\[Lang\\]\\[266\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"kernel/util/ocr.go","lineNumber":161,"sourceCode":"\tassetsTextsLock.Lock()\n\toldText, ok := assetsTexts[asset]\n\tassetsTexts[asset] = text\n\tassetsTextsLock.Unlock()\n\tif !ok || oldText != text {\n\t\tassetsTextsChanged.Store(true)\n\t}\n}\n\nfunc ExistsAssetText(asset string) (ret bool) {\n\tassetsTextsLock.Lock()\n\t_, ret = assetsTexts[asset]\n\tassetsTextsLock.Unlock()\n\treturn\n}\n\nfunc OcrAsset(asset string) (ret []map[string]string, err error) {\n\tif !TesseractEnabled {\n\t\terr = errors.New(Langs[Lang][266])\n\t\treturn\n\t}\n\n\tassetsPath := GetDataAssetsAbsPath()\n\tassetAbsPath := strings.TrimPrefix(asset, \"assets\")\n\tassetAbsPath = filepath.Join(assetsPath, assetAbsPath)\n\tret = Tesseract(assetAbsPath)\n\tassetsTextsLock.Lock()\n\tocrText := GetOcrJsonText(ret)\n\tassetsTexts[asset] = ocrText\n\tassetsTextsLock.Unlock()\n\tif \"\" != ocrText {\n\t\tassetsTextsChanged.Store(true)\n\t}\n\treturn\n}\n\nfunc GetAssetText(asset string) (ret string) {","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/ocr.go#L143-L179","documentation":"OcrAsset performs Tesseract OCR on an image asset, but only when the TesseractEnabled flag is set (requires the tesseract binary to be found/configured). When OCR is disabled, it returns a localized message from Langs[Lang][266] — the i18n string telling the user OCR is not enabled — instead of running OCR. It is an expected precondition failure, surfaced to the UI as a localized notice.","triggerScenarios":"Calling OcrAsset (directly or via the OCR-related API/anonymous caller in asset indexing) when TesseractEnabled is false — i.e. the tesseract executable was not detected at startup or OCR was turned off in settings, yet an OCR request/asset-text rebuild was issued.","commonSituations":"Tesseract not installed on Linux server/desktop builds (SiYuan does not bundle it everywhere); PATH lacking the tesseract binary; user invokes 'extract image text' or rebuilds asset OCR index after disabling OCR; Docker image without tesseract installed.","solutions":["Install tesseract-ocr (plus required language packs, e.g. tesseract-ocr-chi-sim) and make sure it is on PATH, then restart SiYuan","Enable the OCR setting in SiYuan (Settings - Assets - OCR / enable Tesseract) after installation","If OCR is intentionally off, stop issuing OCR requests; the error is expected in this state","In containerized deployments, switch to an image variant that includes tesseract or add it to the Dockerfile"],"exampleFix":"// before\ntexts, _ := util.OcrAsset(asset) // error: OCR not enabled\n// after\nif util.TesseractEnabled {\n    texts, err := util.OcrAsset(asset)\n    if err != nil { return err }\n} else {\n    return errors.New(\"tesseract OCR is not installed or disabled; install tesseract-ocr and enable it in settings\")\n}","handlingStrategy":"fallback","validationCode":"// Go: skip OCR work when Tesseract is not enabled\nif !util.TesseractEnabled {\n    return nil // or handle asset without OCR text\n}","typeGuard":null,"tryCatchPattern":"texts, err := util.OcrAsset(asset)\nif err != nil {\n    if strings.Contains(err.Error(), util.Langs[util.Lang][266]) {\n        logging.LogWarnf(\"OCR disabled, skipping asset %s\", asset)\n        return nil\n    }\n    return err\n}","preventionTips":["Install tesseract-ocr and language packs before enabling OCR-dependent features","Verify tesseract is on PATH at deployment time and check TesseractEnabled after kernel startup","Gate OCR-calling code paths on util.TesseractEnabled so disabled OCR degrades gracefully","In Docker, use an image variant that ships tesseract or add it explicitly to the image build"],"tags":["go","ocr","tesseract","i18n"],"backgroundTag":"feature-not-enabled","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}