{"record":{"id":"b8a91e88ff960f53","repo":"didi/DoKit","slug":"path-must-not-be-empty","errorCode":null,"errorMessage":"Path must not be empty.","messagePattern":"Path must not be empty\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java","lineNumber":298,"sourceCode":"   * <p>\n   * This path may be a remote URL, file resource (prefixed with {@code file:}), content resource\n   * (prefixed with {@code content:}), or android resource (prefixed with {@code\n   * android.resource:}.\n   * <p>\n   * Passing {@code null} as a {@code path} will not trigger any request but will set a\n   * placeholder, if one is specified.\n   *\n   * @see #load(Uri)\n   * @see #load(File)\n   * @see #load(int)\n   * @throws IllegalArgumentException if {@code path} is empty or blank string.\n   */\n  public RequestCreator load(String path) {\n    if (path == null) {\n      return new RequestCreator(this, null, 0);\n    }\n    if (path.trim().length() == 0) {\n      throw new IllegalArgumentException(\"Path must not be empty.\");\n    }\n    return load(Uri.parse(path));\n  }\n\n  /**\n   * Start an image request using the specified image file. This is a convenience method for\n   * calling {@link #load(Uri)}.\n   * <p>\n   * Passing {@code null} as a {@code file} will not trigger any request but will set a\n   * placeholder, if one is specified.\n   * <p>\n   * Equivalent to calling {@link #load(Uri) load(Uri.fromFile(file))}.\n   *\n   * @see #load(Uri)\n   * @see #load(String)\n   * @see #load(int)\n   */\n  public RequestCreator load(File file) {","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/didi/DoKit/blob/626827cddb2feb2f3aee87a52a064b4e5ca2bed4/Android/dokit/src/main/java/com/didichuxing/doraemonkit/picasso/DokitPicasso.java#L280-L316","documentation":"DokitPicasso.load(String path) treats null as a deliberate no-op request (placeholder-only) but rejects empty or whitespace-only strings with IllegalArgumentException('Path must not be empty.'), because Uri.parse(\"\") would produce a request no handler can serve. It is an argument-contract error: the caller passed a string, but it carries no usable location.","triggerScenarios":"load(\"\") or load(\"   \") from a model field that was never populated; data binding where the path expression evaluates to empty; trailing/leading whitespace introduced by JSON trimming bugs; lint-blocking null checks converted to empty strings.","commonSituations":"Feed items with an optional image URL where the server sends \"\" instead of null; getString(R.string.x) returning empty in flavor builds.","solutions":["Normalize before loading: treat blank strings as absent, same as null","Fix the producer so optional fields are null rather than empty strings","Use .error(placeholder) plus the guard so the UI still shows something"],"exampleFix":"// before\nDokitPicasso.with(context).load(item.avatarUrl).into(avatar); // avatarUrl == \"\"\n\n// after\nRequestCreator rq = (item.avatarUrl == null || item.avatarUrl.trim().isEmpty())\n    ? DokitPicasso.with(context).load(R.drawable.avatar_placeholder)\n    : DokitPicasso.with(context).load(item.avatarUrl);\nrq.into(avatar);","handlingStrategy":"validation","validationCode":"static boolean isBlank(String s) { return s == null || s.trim().isEmpty(); }\n\nRequestCreator rq = isBlank(path)\n    ? picasso.load(R.drawable.placeholder)\n    : picasso.load(path);\nrq.into(view);","typeGuard":null,"tryCatchPattern":"// Cheap guard makes try-catch unnecessary; if calling untrusted code:\ntry {\n  picasso.load(path).into(view);\n} catch (IllegalArgumentException e) {\n  if (\"Path must not be empty.\".equals(e.getMessage())) {\n    view.setImageResource(R.drawable.placeholder);\n  } else throw e;\n}","preventionTips":["Normalize optional image fields to null at the data layer; treat blank as absent","Kotlin: model URLs as String? and gate loads with if (!url.isNullOrBlank())","Add .error(placeholder) everywhere optional images load"],"tags":["android","picasso","validation","argument"],"backgroundTag":null,"analyzedSha":"626827cddb2feb2f3aee87a52a064b4e5ca2bed4","analyzedAt":"2026-08-14T12:45:58.758Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}