{"record":{"id":"f11cd3aa6ba9c19b","repo":"SubtitleEdit/subtitleedit","slug":"google-lens-ocr-does-not-support-this-platform","errorCode":null,"errorMessage":"Google Lens OCR does not support this platform","messagePattern":"Google Lens OCR does not support this platform","errorType":"exception","errorClass":"PlatformNotSupportedException","httpStatus":null,"severity":"critical","filePath":"src/ui/Logic/Download/GoogleLensOcrDownloadService.cs","lineNumber":50,"sourceCode":"\n    private string GetUrl()\n    {\n        if (OperatingSystem.IsWindows())\n        {\n            return WindowsUrl;\n        }\n\n        if (OperatingSystem.IsLinux())\n        {\n            if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)\n            {\n                throw new PlatformNotSupportedException(\"Google Lens OCR is not available for Linux ARM64.\");\n            }\n\n            return LinuxUrl;\n        }\n\n        throw new PlatformNotSupportedException(\"Google Lens OCR does not support this platform\");\n    }\n}","sourceCodeStart":32,"sourceCodeEnd":52,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Logic/Download/GoogleLensOcrDownloadService.cs#L32-L52","documentation":"Terminal fallback thrown by GoogleLensOcrDownloadService.GetUrl() when the OS is neither Windows nor Linux. The service has URLs only for Windows and Linux x64; macOS and any other OS fall through to this catch-all PlatformNotSupportedException.","triggerScenarios":"OperatingSystem.IsMacOS() is true (or FreeBSD/other) and the caller asks for a Google Lens OCR URL. macOS has no URL constant defined, so it reaches the final throw.","commonSituations":"Mac users attempting Google Lens OCR; unsupported OSes (FreeBSD, etc.); running under a non-Windows/Linux container. This is the platform gate that keeps macOS users from a downstream FileNotFoundException.","solutions":["Use Google Lens OCR only on Windows or Linux x64.","Disable the feature on macOS/unsupported OSes at the UI/caller level before invoking GetUrl().","If macOS support is needed, obtain a macOS-compatible Google Lens OCR build and wire a MacUrl into the method."],"exampleFix":"// before\nvar url = googleLensService.GetUrl(); // throws on macOS\n\n// after\nif (!OperatingSystem.IsWindows() && !(OperatingSystem.IsLinux() && RuntimeInformation.ProcessArchitecture != Architecture.Arm64))\n{\n    DisableGoogleLensOcrFeature();\n    return;\n}\nvar url = googleLensService.GetUrl();","handlingStrategy":"validation","validationCode":"static bool IsGoogleLensOcrSupportedPlatform()\n    => OperatingSystem.IsWindows()\n       || (OperatingSystem.IsLinux() && RuntimeInformation.ProcessArchitecture != Architecture.Arm64);\n\nif (!IsGoogleLensOcrSupportedPlatform()) { DisableGoogleLensOcr(); return; }","typeGuard":"static bool GoogleLensOcrPlatformSupported()\n    => OperatingSystem.IsWindows()\n       || (OperatingSystem.IsLinux() && RuntimeInformation.ProcessArchitecture != Architecture.Arm64);","tryCatchPattern":"try { var url = googleLensService.GetUrl(); }\ncatch (PlatformNotSupportedException ex) when (ex.Message.Contains(\"does not support this platform\"))\n{ _logger.Warning(\"Google Lens OCR not supported on {OS}\", RuntimeInformation.OSDescription); DisableGoogleLensOcr(); }","preventionTips":["Restrict the Google Lens OCR feature to Windows/Linux-x64 in the UI.","Do not advertise the OCR option on macOS in feature matrices.","Centralize platform support tables to avoid scattered checks."],"tags":["platform","macos","unsupported-os","google-lens","ocr","download"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}