Leantime/leantime · error · Exception
comments module needs to be initialized with module, entity
Error message
comments module needs to be initialized with module, entity id and entity
What it means
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.
Source
Thrown at app/Domain/Comments/Controllers/ShowAll.php:39
/**
* init - initialize private variables
*
* @throws Exception
*/
public function init(
CommentService $commentService
): void {
$this->commentService = $commentService;
}
/**
* @throws Exception
*/
public function get($params): Response
{
if (! isset($params['module'], $params['entitiyId'], $params['entity'])) {
throw new Exception('comments module needs to be initialized with module, entity id and entity');
}
$this->module = $params['module'];
$this->id = $params['entitiyId'];
$this->entity = $params['entity'];
$comments = $this->commentService->getComments($this->module, $this->id);
$this->tpl->assign('numComments', count($comments));
$this->tpl->assign('comments', $comments);
// Delete comment
if (isset($params['delComment']) === true) {
$commentId = (int) ($params['delComment']);
if ($this->commentService->deleteComment($commentId)) {
$this->tpl->setNotification($this->language->__('notifications.comment_deleted'), 'success');
View on GitHub (pinned to 9a9f49f100)
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
Example fix
// before (broken link) <a href="<?= BASE_URL ?>/comments/showAll">Comments</a> // after <a href="<?= BASE_URL ?>/comments/showAll?module=<?= $module ?>&entitiyId=<?= $id ?>&entity=<?= $entity ?>">Comments</a>
Defensive patterns
Strategy: validation
Validate before calling
$required = ['module', 'entitiyId', 'entity']; // note the 'entitiyId' spelling
$missing = array_diff($required, array_keys($params));
if ($missing !== []) {
throw new \InvalidArgumentException('comments/showAll missing: '.implode(',', $missing));
} Type guard
function isCompleteCommentsRequest(array $params): bool
{
// 'entitiyId' is the historical (misspelled) key the controller checks
return isset($params['module'], $params['entitiyId'], $params['entity']);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
AI-assisted analysis of Leantime/leantime@9a9f49f100 (2026-08-21).
Data as JSON: /api/errors/67a18428b1b0bbc2.
Report an issue: GitHub.