{"record":{"id":"9c057706ea5d747b","repo":"zxing/zxing","slug":"data-too-big-for-requested-version","errorCode":null,"errorMessage":"Data too big for requested version","messagePattern":"Data too big for requested version","errorType":"exception","errorClass":"WriterException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/google/zxing/qrcode/encoder/Encoder.java","lineNumber":149,"sourceCode":"      if (hasGS1FormatHint) {\n        // GS1 formatted codes are prefixed with a FNC1 in first position mode header\n        appendModeInfo(Mode.FNC1_FIRST_POSITION, headerBits);\n      }\n\n      // (With ECI in place,) Write the mode marker\n      appendModeInfo(mode, headerBits);\n\n      // Collect data within the main segment, separately, to count its size if needed. Don't add it to\n      // main payload yet.\n      BitArray dataBits = new BitArray();\n      appendBytes(content, mode, dataBits, encoding);\n\n      if (hints != null && hints.containsKey(EncodeHintType.QR_VERSION)) {\n        int versionNumber = Integer.parseInt(hints.get(EncodeHintType.QR_VERSION).toString());\n        version = Version.getVersionForNumber(versionNumber);\n        int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version);\n        if (!willFit(bitsNeeded, version, ecLevel)) {\n          throw new WriterException(\"Data too big for requested version\");\n        }\n      } else {\n        version = recommendVersion(ecLevel, mode, headerBits, dataBits);\n      }\n\n      headerAndDataBits = new BitArray();\n      headerAndDataBits.appendBitArray(headerBits);\n      // Find \"length\" of main segment and write it\n      int numLetters = mode == Mode.BYTE ? dataBits.getSizeInBytes() : content.length();\n      appendLengthInfo(numLetters, version, mode, headerAndDataBits);\n      // Put data together into the overall payload\n      headerAndDataBits.appendBitArray(dataBits);\n    }\n\n    Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);\n    int numDataBytes = version.getTotalCodewords() - ecBlocks.getTotalECCodewords();\n\n    // Terminate the bits properly.","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/zxing/zxing/blob/19aa2d8254410e161f04dc3c928e68d5e90233c2/core/src/main/java/com/google/zxing/qrcode/encoder/Encoder.java#L131-L167","documentation":"Error \"Data too big for requested version\" thrown in zxing/zxing.","triggerScenarios":"Thrown at core/src/main/java/com/google/zxing/qrcode/encoder/Encoder.java:149 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request a larger QR version, reduce the data, or lower the error correction level.","Let the encoder choose the version automatically instead of pinning a small version."],"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"}