{"record":{"id":"7dd04849f767f21f","repo":"Dolibarr/dolibarr","slug":"error-parameter-generator-or-encoding-not-defined","errorCode":null,"errorMessage":"Error: Parameter \"generator\" or \"encoding\" not defined","messagePattern":"Error: Parameter \"generator\" or \"encoding\" not defined","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"htdocs/viewimage.php","lineNumber":390,"sourceCode":"\t\t$code = '';\n\t\tif ($vcffile && $id) {\n\t\t\t// Case of use of viewimage to get the barcode for user pubic profile,\n\t\t\t// we must check the securekey that protet against forging url\n\t\t\tif ($reg[1] == 'user' && (int) $reg[2] > 0) {\n\t\t\t\t$encodedsecurekey = dol_hash($conf->file->instance_unique_id.'uservirtualcard'.$id.'-'.$login, 'md5');\n\t\t\t\tif ($encodedsecurekey != GETPOST('securekey')) {\n\t\t\t\t\t$code = 'badvalueforsecurekey';\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (empty($code)) {\n\t\t\t\t$code = file_get_contents($vcffile);\n\t\t\t}\n\t\t}\n\t}\n\n\n\tif (empty($generator) || empty($encoding)) {\n\t\tprint 'Error: Parameter \"generator\" or \"encoding\" not defined';\n\t\texit;\n\t}\n\n\t$dirbarcode = array_merge(array(\"/core/modules/barcode/doc/\"), $conf->modules_parts['barcode']);\n\n\t$result = 0;\n\n\tforeach ($dirbarcode as $reldir) {\n\t\t$dir = dol_buildpath($reldir, 0);\n\t\t$newdir = dol_osencode($dir);\n\n\t\t// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)\n\t\tif (!is_dir($newdir)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t$result = @include_once $newdir.$generator.'.modules.php';\n\t\tif ($result) {","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/viewimage.php#L372-L408","documentation":"When modulepart is 'barcode', viewimage.php requires the GET parameters 'generator' (barcode generator class) and 'encoding' (barcode type) to both be non-empty; one or both are missing, so no barcode image can be produced and the request is aborted.","triggerScenarios":"Thrown at htdocs/viewimage.php:390 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the missing generator parameter (e.g. generator=camel of the barcode generator class) to the URL","Add the missing encoding parameter (e.g. encoding=EAN13, C128, QRCODE) to the URL","Fix the code/template that builds the barcode image URL so both parameters are always supplied","If using the vcffile path, ensure the preceding logic that derives generator/encoding from the vcard ran correctly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"598aa4bdada683d17ca04b1842548821ff0eb6c6","analyzedAt":"2026-09-14T11:12:15.309Z","contentChangedAt":"2026-09-14T11:12:15.309Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}