{"record":{"id":"3e04862cf7d5bafc","repo":"Dolibarr/dolibarr","slug":"bad-link-missing-identification-to-find-file-param-file-or","errorCode":null,"errorMessage":"Bad link. Missing identification to find file (param file or hashp)","messagePattern":"Bad link\\. Missing identification to find file \\(param file or hashp\\)","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"htdocs/viewimage.php","lineNumber":180,"sourceCode":" * @var Translate $langs\n * @var User $user\n */\nrequire_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';\n\n$action = GETPOST('action', 'aZ09');\n$original_file = GETPOST('file', 'alphanohtml');\n$hashp = GETPOST('hashp', 'aZ09', 1);\n$extname = GETPOST('extname', 'alpha', 1);\n$modulepart = GETPOST('modulepart', 'alpha', 1);\n$urlsource = GETPOST('urlsource', 'alpha');\n$entity = ($entity > 0 ? $entity : $conf->entity);\n\n// Security check\nif (empty($modulepart) && empty($hashp)) {\n\thttponly_accessforbidden('Bad link. Bad value for parameter modulepart', 400);\n}\nif (empty($original_file) && empty($hashp) && $modulepart != 'barcode') {\n\thttponly_accessforbidden('Bad link. Missing identification to find file (param file or hashp)', 400);\n}\nif ($hashp == 'shared') {\n\thttponly_accessforbidden('Bad link. Bad value for parameter hashp', 400);\n}\nif ($modulepart == 'fckeditor') {\n\t$modulepart = 'medias'; // For backward compatibility\n}\n\n\n/*\n * Actions\n */\n\n// None\n\n\n\n/*","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/viewimage.php#L162-L198","documentation":"viewimage.php requires some identification of the file: if original_file (param file) is empty and hashp is empty and modulepart is not 'barcode', it returns 400 'Bad link. Missing identification to find file (param file or hashp)'. The script needs either a module-relative path or an ecm hash to locate the image.","triggerScenarios":"GET viewimage.php?modulepart=medias with no file parameter; file parameter dropped by an URL builder; modulepart=barcode exemption not applying because modulepart is something else; hashp empty string treated as missing.","commonSituations":"Thumbnail generators calling viewimage without forwarding the file param; broken links after migration to hashp-based URLs; custom code that only passes modulepart assuming a default filename.","solutions":["Append &file=<relative path> to the viewimage URL","Or generate a shared link with hashp via ecm file hash (dol_buildHashic / getFileLink using hashp)","For barcode images set modulepart=barcode and pass the code parameters","Fix the caller so the file parameter is not stripped (urlencode it)"],"exampleFix":"// before\n$url = DOL_URL_ROOT.'/viewimage.php?modulepart=medias';\n// after\n$url = DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.urlencode($relativepath);","handlingStrategy":"validation","validationCode":"if (empty($file) && empty($hashp) && $modulepart !== 'barcode') { throw new InvalidArgumentException('file or hashp required'); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Forward the file parameter through thumbnail/link builders; urlencode it","Prefer generated image URL helpers (e.g. showPhoto, dol_print_picture) over manual URLs","For shared/public images pass hashp instead of file","Assert parameters exist in integration tests for pages rendering images"],"tags":["http-400","viewimage","missing-parameter","dolibarr"],"backgroundTag":"missing-required-argument","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"}