{"record":{"id":"67a18428b1b0bbc2","repo":"Leantime/leantime","slug":"comments-module-needs-to-be-initialized-with-modul","errorCode":null,"errorMessage":"comments module needs to be initialized with module, entity id and entity","messagePattern":"comments module needs to be initialized with module, entity id and entity","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"app/Domain/Comments/Controllers/ShowAll.php","lineNumber":39,"sourceCode":"\n    /**\n     * init - initialize private variables\n     *\n     * @throws Exception\n     */\n    public function init(\n        CommentService $commentService\n    ): void {\n        $this->commentService = $commentService;\n    }\n\n    /**\n     * @throws Exception\n     */\n    public function get($params): Response\n    {\n        if (! isset($params['module'], $params['entitiyId'], $params['entity'])) {\n            throw new Exception('comments module needs to be initialized with module, entity id and entity');\n        }\n\n        $this->module = $params['module'];\n        $this->id = $params['entitiyId'];\n        $this->entity = $params['entity'];\n\n        $comments = $this->commentService->getComments($this->module, $this->id);\n\n        $this->tpl->assign('numComments', count($comments));\n        $this->tpl->assign('comments', $comments);\n\n        // Delete comment\n        if (isset($params['delComment']) === true) {\n            $commentId = (int) ($params['delComment']);\n\n            if ($this->commentService->deleteComment($commentId)) {\n                $this->tpl->setNotification($this->language->__('notifications.comment_deleted'), 'success');\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/Leantime/leantime/blob/9a9f49f1008f4782b30f6723c54228f4f992e636/app/Domain/Comments/Controllers/ShowAll.php#L21-L57","documentation":"The Comments ShowAll page controller (routed via the Frontcontroller as /comments/showAll and embedded with displaySubmodule) refuses to render unless the request carries all three parameters: 'module', 'entitiyId' and 'entity'. Note the historical misspelling: the id key is 'entitiyId' (extra 'i'), not 'entityId'. It throws a plain \\Exception with no error code, so it surfaces as an HTTP 500 rather than a structured JSON-RPC error.","triggerScenarios":"Opening /comments/showAll without ?module=...&entitiyId=...&entity=...; passing the correctly spelled 'entityId' key (the isset fails); a custom template embedding the comments submodule without forwarding the three params; a redirect that drops the query string.","commonSituations":"Developers writing new templates that include the comments partial and guessing the parameter names; links built by string concatenation that omit the query string; refactors that rename URL params.","solutions":["Append all three query parameters, spelling the id key exactly 'entitiyId': /comments/showAll?module=tickets&entitiyId=42&entity=ticket","When embedding, use the documented submodule alias/displaySubmodule call so Leantime forwards the params for you","Wrap custom embeds in a check that all three keys exist before issuing the request, and log the actual param names received"],"exampleFix":"// before (broken link)\n<a href=\"<?= BASE_URL ?>/comments/showAll\">Comments</a>\n\n// after\n<a href=\"<?= BASE_URL ?>/comments/showAll?module=<?= $module ?>&entitiyId=<?= $id ?>&entity=<?= $entity ?>\">Comments</a>","handlingStrategy":"validation","validationCode":"$required = ['module', 'entitiyId', 'entity']; // note the 'entitiyId' spelling\n$missing = array_diff($required, array_keys($params));\nif ($missing !== []) {\n    throw new \\InvalidArgumentException('comments/showAll missing: '.implode(',', $missing));\n}","typeGuard":"function isCompleteCommentsRequest(array $params): bool\n{\n    // 'entitiyId' is the historical (misspelled) key the controller checks\n    return isset($params['module'], $params['entitiyId'], $params['entity']);\n}","tryCatchPattern":null,"preventionTips":["Always build the comments URL with all three params, copying the literal key 'entitiyId' (sic)","Prefer Leantime's submodule embedding (displaySubmodule) which forwards the params for you","Add a regression test asserting the three keys exist before rendering any custom comments embed"],"tags":["comments","controller","query-params","typo","http-500"],"backgroundTag":"missing-required-parameter","analyzedSha":"9a9f49f1008f4782b30f6723c54228f4f992e636","analyzedAt":"2026-08-21T02:37:38.966Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}