{"record":{"id":"226122afcaf71def","repo":"apache/beam","slug":"lenientformat-errormessagetemplate-p1","errorCode":null,"errorMessage":"lenientFormat(errorMessageTemplate, p1)","messagePattern":"lenientFormat\\(errorMessageTemplate, p1\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/Preconditions.java","lineNumber":114,"sourceCode":"      @Nullable Object... errorMessageArgs) {\n    if (reference == null) {\n      throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, errorMessageArgs));\n    }\n    return reference;\n  }\n\n  /**\n   * Ensures that an object reference passed as a parameter to the calling method is not null.\n   *\n   * <p>See {@link #checkArgumentNotNull(Object, String, Object...)} for details.\n   */\n  @CanIgnoreReturnValue\n  @EnsuresNonNull(\"#1\")\n  @Pure\n  public static <T extends @NonNull Object> T checkArgumentNotNull(\n      @Nullable T obj, @Nullable String errorMessageTemplate, char p1) {\n    if (obj == null) {\n      throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));\n    }\n    return obj;\n  }\n\n  /**\n   * Ensures that an object reference passed as a parameter to the calling method is not null.\n   *\n   * <p>See {@link #checkArgumentNotNull(Object, String, Object...)} for details.\n   */\n  @CanIgnoreReturnValue\n  @EnsuresNonNull(\"#1\")\n  @Pure\n  public static <T extends @NonNull Object> T checkArgumentNotNull(\n      @Nullable T obj, @Nullable String errorMessageTemplate, int p1) {\n    if (obj == null) {\n      throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, p1));\n    }\n    return obj;","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/Preconditions.java#L96-L132","documentation":"The single-arg (char p1) overload of checkArgumentNotNull throws IllegalArgumentException with lenientFormat(template, p1) when the object is null. It avoids varargs boxing for the common one-character-argument message case.","triggerScenarios":"Passing a null object to an API that validates with checkArgumentNotNull(obj, template, char p1); the thrown message embeds the char argument.","commonSituations":"Same as other checkArgumentNotNull overloads: null values (often configuration or lookup results) reaching Beam APIs during pipeline setup.","solutions":["Guarantee the argument is non-null before the call.","Use the exception message to locate the null value.","Initialize defaults or fail fast during configuration parsing."],"exampleFix":"// before\nPreconditions.checkArgumentNotNull(obj, \"Bad shard char %s\", c);\n// after\nPreconditions.checkArgumentNotNull(loadObj(), \"Bad shard char %s\", c);","handlingStrategy":"validation","validationCode":"if (obj == null) throw new IllegalArgumentException(String.format(template, p1));","typeGuard":"null","tryCatchPattern":"try { apiCall(obj); } catch (IllegalArgumentException e) { LOG.error(\"validation failed: {}\", e.getMessage()); }","preventionTips":["Initialize required objects with defaults before validation","Check nullability of lookups/reads before passing values onward","Use message templates that name the offending field"],"tags":["java","null-check","arguments"],"backgroundTag":"null-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}