{"record":{"id":"8766582db196e552","repo":"bumptech/glide","slug":"filedescriptor-is-null-for-uri-876658","errorCode":null,"errorMessage":"FileDescriptor is null for: {uri}","messagePattern":"FileDescriptor is null for: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/load/data/FileDescriptorLocalUriFetcher.java","lineNumber":31,"sourceCode":"  public FileDescriptorLocalUriFetcher(ContentResolver contentResolver, Uri uri) {\n    super(contentResolver, uri);\n  }\n\n  /**\n   * useMediaStoreApisIfAvailable is part of an experiment and the constructor can be removed in a\n   * future version.\n   */\n  public FileDescriptorLocalUriFetcher(\n      ContentResolver contentResolver, Uri uri, boolean useMediaStoreApisIfAvailable) {\n    super(contentResolver, uri, useMediaStoreApisIfAvailable);\n  }\n\n  @Override\n  protected ParcelFileDescriptor loadResource(Uri uri, ContentResolver contentResolver)\n      throws FileNotFoundException {\n    AssetFileDescriptor assetFileDescriptor = openAssetFileDescriptor(uri);\n    if (assetFileDescriptor == null) {\n      throw new FileNotFoundException(\"FileDescriptor is null for: \" + uri);\n    }\n    return assetFileDescriptor.getParcelFileDescriptor();\n  }\n\n  @Override\n  protected void close(ParcelFileDescriptor data) throws IOException {\n    data.close();\n  }\n\n  @NonNull\n  @Override\n  public Class<ParcelFileDescriptor> getDataClass() {\n    return ParcelFileDescriptor.class;\n  }\n}\n","sourceCodeStart":13,"sourceCodeEnd":47,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/load/data/FileDescriptorLocalUriFetcher.java#L13-L47","documentation":"FileDescriptorLocalUriFetcher loads a local content Uri via openAssetFileDescriptor and then extracts the ParcelFileDescriptor. If the ContentResolver returns null for openAssetFileDescriptor, there is no file descriptor to read, and Glide throws a FileNotFoundException naming the Uri. This is the ParcelFileDescriptor-based counterpart of the AssetFileDescriptor fetcher.","triggerScenarios":"Loading a video thumbnail or local file Uri via the FileDescriptor path when the content has been deleted. Content provider does not support openAssetFileDescriptor for the given Uri. Permission to access the content was revoked.","commonSituations":"Loading video frames from a MediaStore Uri after the media file was moved or deleted. Accessing content from another app's FileProvider without proper grants. Background service loading media after a user cleared app data.","solutions":["Verify content exists at the Uri using ContentResolver#query before loading","Add an .error() placeholder and handle the failure gracefully in RequestListener","Ensure persisted URI permissions (takePersistableUriPermission) are still valid if using a persisted Uri","Register a custom data fetcher if the content provider only supports openInputStream"],"exampleFix":"// before\nGlide.with(context).load(videoUri).into(imageView);\n// after\nGlide.with(context)\n  .load(videoUri)\n  .error(R.drawable.video_placeholder)\n  .into(imageView);","handlingStrategy":"try-catch","validationCode":"// Verify content exists before loading\nprivate boolean contentExists(ContentResolver cr, Uri uri) {\n  try (Cursor c = cr.query(uri, null, null, null, null)) {\n    return c != null && c.getCount() > 0;\n  } catch (Exception e) {\n    return false;\n  }\n}\nif (contentExists(getContentResolver(), uri)) {\n  Glide.with(context).load(uri).into(imageView);\n}","typeGuard":null,"tryCatchPattern":"Glide.with(context)\n  .load(uri)\n  .error(R.drawable.placeholder)\n  .listener(new RequestListener<Drawable>() {\n    @Override public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {\n      for (Throwable root : e.getRootCauses()) {\n        if (root instanceof FileNotFoundException) {\n          Log.w(TAG, \"FileDescriptor unavailable for \" + model);\n        }\n      }\n      return false;\n    }\n    @Override public boolean onResourceReady(Drawable r, Object m, Target<Drawable> t, DataSource d, boolean i) { return false; }\n  })\n  .into(imageView);","preventionTips":["Verify persisted Uri permissions are still valid before loading","Check that content exists via ContentResolver#query before loading","Provide .error() placeholders for all local content loads","Handle cases where the content provider does not support openAssetFileDescriptor"],"tags":["glide","uri","content-resolver","file-not-found"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}