{"record":{"id":"9c081dca75c62b1e","repo":"termux/termux-app","slug":"not-found","errorCode":null,"errorMessage":" not found","messagePattern":" not found","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"warning","filePath":"app/src/main/java/com/termux/filepicker/TermuxDocumentsProvider.java","lineNumber":212,"sourceCode":"        return documentId.startsWith(parentDocumentId);\n    }\n\n    /**\n     * Get the document id given a file. This document id must be consistent across time as other\n     * applications may save the ID and use it to reference documents later.\n     * <p/>\n     * The reverse of @{link #getFileForDocId}.\n     */\n    private static String getDocIdForFile(File file) {\n        return file.getAbsolutePath();\n    }\n\n    /**\n     * Get the file given a document id (the reverse of {@link #getDocIdForFile(File)}).\n     */\n    private static File getFileForDocId(String docId) throws FileNotFoundException {\n        final File f = new File(docId);\n        if (!f.exists()) throw new FileNotFoundException(f.getAbsolutePath() + \" not found\");\n        return f;\n    }\n\n    private static String getMimeType(File file) {\n        if (file.isDirectory()) {\n            return Document.MIME_TYPE_DIR;\n        } else {\n            final String name = file.getName();\n            final int lastDot = name.lastIndexOf('.');\n            if (lastDot >= 0) {\n                final String extension = name.substring(lastDot + 1).toLowerCase();\n                final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);\n                if (mime != null) return mime;\n            }\n            return \"application/octet-stream\";\n        }\n    }\n","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/termux/termux-app/blob/3df69d1da197dd9bd71a3bafd902dffd720576b4/app/src/main/java/com/termux/filepicker/TermuxDocumentsProvider.java#L194-L230","documentation":"Thrown by getFileForDocId when the File constructed from the document id does not exist (File.exists() returns false). This is the standard 'document not found' signal for a DocumentsProvider: SAF clients expect FileNotFoundException when referencing a deleted or never-existed document.","triggerScenarios":"The client holds a stale document id referencing a file/dir that was deleted; the docId string is wrong or from a different root; the underlying storage was unmounted; a race where the file is deleted between query and open.","commonSituations":"SAF persistent URI permission points to a removed file; directory listing cached after deletion; user manually deleted the file outside the provider.","solutions":["Treat FileNotFoundException as 'gone' and refresh/remove the stale reference in the client.","Before operating on a persisted docId, re-query the provider to confirm existence.","Ensure the storage holding the file is mounted.","Avoid caching document ids across sessions without re-validation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"File file = new File(docId);\nif (!file.exists()) {\n    // refresh client state; do not call provider with stale id\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    return provider.openDocument(uri, mode, signal);\n} catch (FileNotFoundException e) {\n    // refresh document tree; the id is stale\n    refreshDocumentList();\n    throw e;\n}","preventionTips":["Re-query the provider before operating on persisted document ids.","Do not cache document ids across app sessions without re-validation.","Handle FileNotFoundException as 'document removed' in the UI."],"tags":["documents-provider","saf","filesystem","termux"],"backgroundTag":null,"analyzedSha":"3df69d1da197dd9bd71a3bafd902dffd720576b4","analyzedAt":"2026-08-13T22:46:28.294Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}