{"record":{"id":"979b94d32d890f17","repo":"bumptech/glide","slug":"must-not-be-empty","errorCode":null,"errorMessage":"Must not be empty.","messagePattern":"Must not be empty\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/bumptech/glide/util/Preconditions.java","lineNumber":49,"sourceCode":"  public static <T> T checkNotNull(@Nullable T arg, @NonNull String message) {\n    if (arg == null) {\n      throw new NullPointerException(message);\n    }\n    return arg;\n  }\n\n  @NonNull\n  public static String checkNotEmpty(@Nullable String string) {\n    if (TextUtils.isEmpty(string)) {\n      throw new IllegalArgumentException(\"Must not be null or empty\");\n    }\n    return string;\n  }\n\n  @NonNull\n  public static <T extends Collection<Y>, Y> T checkNotEmpty(@NonNull T collection) {\n    if (collection.isEmpty()) {\n      throw new IllegalArgumentException(\"Must not be empty.\");\n    }\n    return collection;\n  }\n}\n","sourceCodeStart":31,"sourceCodeEnd":54,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/library/src/main/java/com/bumptech/glide/util/Preconditions.java#L31-L54","documentation":"Thrown by Preconditions.checkNotEmpty(Collection) when a non-null Collection is empty (collection.isEmpty()). Used internally where Glide requires at least one element: empty model lists, empty header maps, empty key sets, etc.","triggerScenarios":"Passing an empty List/Set/Map to a Glide API that requires at least one entry; e.g. an empty list of URLs to a multi-model load, an empty headers map, an empty set of decoder keys.","commonSituations":"UI state where a list of items is filtered down to zero before bind; deserialized JSON collections that came back empty; default-initialized empty collections passed where required.","solutions":["Guard with if (!collection.isEmpty()) before calling the API","Provide a fallback branch (placeholder / skip load) for the empty case","Use Kotlin's collection.takeIf { it.isNotEmpty() }?.let { ... }","Validate parsed data upstream and either skip rendering or show an empty-state view"],"exampleFix":"// before\nGlide.with(ctx).load(urls).into(imageView) // urls may be emptyList()\n\n// after\nif (urls.isNotEmpty()) {\n  Glide.with(ctx).load(urls).into(imageView)\n} else {\n  imageView.setImageResource(R.drawable.placeholder)\n}","handlingStrategy":"validation","validationCode":"if (urls.isNotEmpty()) {\n  Glide.with(ctx).load(urls).into(imageView)\n} else {\n  imageView.setImageResource(R.drawable.placeholder)\n}","typeGuard":"fun <T> Collection<T>.isNonEmpty(): Boolean = !isEmpty()","tryCatchPattern":null,"preventionTips":["Check collection.isNotEmpty() before passing to Glide APIs that require entries","Show an empty-state UI when collections are empty rather than forcing a load","Validate parsed JSON collections upstream"],"tags":["android","glide","validation","empty-check","preconditions"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}