Dolibarr/dolibarr · error
Error: Parameter "generator" or "encoding" not defined
Error message
Error: Parameter "generator" or "encoding" not defined
What it means
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.
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at htdocs/viewimage.php:390 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14).
Data as JSON: /api/errors/7dd04849f767f21f.
Report an issue: GitHub.
Appendix: source
Thrown at htdocs/viewimage.php:390
$code = '';
if ($vcffile && $id) {
// Case of use of viewimage to get the barcode for user pubic profile,
// we must check the securekey that protet against forging url
if ($reg[1] == 'user' && (int) $reg[2] > 0) {
$encodedsecurekey = dol_hash($conf->file->instance_unique_id.'uservirtualcard'.$id.'-'.$login, 'md5');
if ($encodedsecurekey != GETPOST('securekey')) {
$code = 'badvalueforsecurekey';
}
}
if (empty($code)) {
$code = file_get_contents($vcffile);
}
}
}
if (empty($generator) || empty($encoding)) {
print 'Error: Parameter "generator" or "encoding" not defined';
exit;
}
$dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
$result = 0;
foreach ($dirbarcode as $reldir) {
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) {
continue;
}
$result = @include_once $newdir.$generator.'.modules.php';
if ($result) {View on GitHub (pinned to 598aa4bdad)