{"record":{"id":"1cf25729567578f7","repo":"zxing/zxing","slug":"found-empty-contents-1cf257","errorCode":null,"errorMessage":"Found empty contents","messagePattern":"Found empty contents","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/google/zxing/qrcode/QRCodeWriter.java","lineNumber":55,"sourceCode":"\n  private static final int QUIET_ZONE_SIZE = 4;\n\n  @Override\n  public BitMatrix encode(String contents, BarcodeFormat format, int width, int height)\n      throws WriterException {\n\n    return encode(contents, format, width, height, null);\n  }\n\n  @Override\n  public BitMatrix encode(String contents,\n                          BarcodeFormat format,\n                          int width,\n                          int height,\n                          Map<EncodeHintType,?> hints) throws WriterException {\n\n    if (contents.isEmpty()) {\n      throw new IllegalArgumentException(\"Found empty contents\");\n    }\n\n    if (format != BarcodeFormat.QR_CODE) {\n      throw new IllegalArgumentException(\"Can only encode QR_CODE, but got \" + format);\n    }\n\n    if (width < 0 || height < 0) {\n      throw new IllegalArgumentException(\"Requested dimensions are too small: \" + width + 'x' +\n          height);\n    }\n\n    ErrorCorrectionLevel errorCorrectionLevel = ErrorCorrectionLevel.L;\n    int quietZone = QUIET_ZONE_SIZE;\n    if (hints != null) {\n      if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {\n        errorCorrectionLevel = ErrorCorrectionLevel.valueOf(hints.get(EncodeHintType.ERROR_CORRECTION).toString());\n      }\n      if (hints.containsKey(EncodeHintType.MARGIN)) {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/zxing/zxing/blob/19aa2d8254410e161f04dc3c928e68d5e90233c2/core/src/main/java/com/google/zxing/qrcode/QRCodeWriter.java#L37-L73","documentation":"Error \"Found empty contents\" thrown in zxing/zxing.","triggerScenarios":"Thrown at core/src/main/java/com/google/zxing/qrcode/QRCodeWriter.java:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass non-empty contents to QRCodeWriter.encode().","Check the input for null/empty before invoking the writer."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"19aa2d8254410e161f04dc3c928e68d5e90233c2","analyzedAt":"2026-08-14T03:07:53.428Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}