Leantime/leantime · warning · Exception

Migration Failed; See below

Error message

Migration Failed; See below

What it means

This browser console.warn fires in the Wiki article view (app/Domain/Wiki/Templates/show.blade.php:484) for users at editor role or above with an open article. The page's inline script needs `window.leantime.tiptapController` (the rich-text editor bundle) to attach the Tiptap editor to #wikiTiptapEditor with autosave against #wikiArticleContent. The guard `if (!editorEl || !textarea || !window.leantime || !window.leantime.tiptapController)` bails with the warning when the editor bundle did not load or did not register its controller, leaving the article in plain-textarea/no-editor mode.

Source

Thrown at app/Command/MigrateCommand.php:121

                if ($getAdminUser !== false && is_array($getAdminUser)) {
                    $userId = $getAdminUser['id'];
                    $usersRepo->patchUser($userId, ['password' => $setupConfig['password'], 'status' => 'a']);

                    $helperService = app()->make(Helper::class);
                    $helperService->createDefaultProject($userId, 'owner');
                }

                if ($silent) {
                    $usersRepo = app()->make(Users::class);
                    $userId = array_values($usersRepo->getUserByEmail($adminEmail))[0];
                    $usersRepo->deleteUser($userId);
                }

                $io->text('Successfully Installed DB');
            }
            $success = $install->updateDB();
            if ($success !== true) {
                throw new Exception('Migration Failed; See below'.PHP_EOL.implode(PHP_EOL, $success));
            }
        } catch (Exception $ex) {
            $io->error($ex);

            return Command::FAILURE;
        }

        $io->success('Database Successfully Migrated');

        return Command::SUCCESS;
    }
}

View on GitHub (pinned to 9a9f49f100)

Solutions

  1. Check the browser console for an earlier JS error — fix that first, since the editor bundle often fails to register its controller because an exception aborted it mid-init.
  2. Rebuild and re-version the frontend assets so the layout references existing files: `make build` (or `make build-dev`) and hard-reload past cache; confirm in the Network tab that the editor bundle containing tiptapController returns 200.
  3. Verify the DOM contract: the page must contain #wikiDocumentWrapper, #wikiTiptapEditor and #wikiArticleContent — restore them if a theme/child template renamed them.
  4. If CSP is blocking the script, adjust the script-src policy in the InitialHeaders middleware (or via plugin filter) to allow the editor bundle's origin/inline needs.
  5. As a last resort for content editing continuity, ensure the plain <textarea> fallback still posts correctly so editors can save unformatted content while the bundle is fixed.

Example fix

// before — bails silently for editors if the bundle is late or missing
if (!editorEl || !textarea || !window.leantime || !window.leantime.tiptapController) {
    console.warn('[Wiki] Tiptap controller not available');
    return;
}

// after — wait for the bundle on DOMContentLoaded/window load before giving up, and surface the fallback
function initWikiTiptap() {
    if (!window.leantime || !window.leantime.tiptapController) {
        console.warn('[Wiki] Tiptap controller not available — falling back to plain textarea');
        var ta = document.getElementById('wikiArticleContent');
        if (ta) ta.style.display = '';
        return;
    }
    /* existing wiring */
}
if (document.readyState === 'complete') initWikiTiptap();
else window.addEventListener('load', initWikiTiptap);
Defensive patterns

Strategy: type-guard

Validate before calling

// Page-level smoke check (dev console or e2e test) before relying on the editor
const ready =
    document.getElementById('wikiTiptapEditor') instanceof HTMLElement &&
    document.getElementById('wikiArticleContent') instanceof HTMLTextAreaElement &&
    typeof window.leantime?.tiptapController?.attach === 'function';
if (!ready) console.warn('[Wiki] Tiptap prerequisites missing — check editor bundle and element ids');

Type guard

function tiptapAvailable() {
    return typeof window === 'object'
        && window.leantime instanceof Object
        && 'tiptapController' in window.leantime
        && typeof window.leantime.tiptapController === 'object';
}

(function initWikiEditor() {
    if (!tiptapAvailable()) {
        console.warn('[Wiki] Tiptap controller not available');
        const ta = document.getElementById('wikiArticleContent');
        if (ta) ta.hidden = false; // explicit textarea fallback instead of a dead editor area
        return;
    }
    // ... existing tiptap wiring
})();

Prevention

When it happens

Trigger: Opening a wiki article as an editor when: (1) the Tiptap/editor JS bundle 404s or is stale because assets were not rebuilt after deploy (`npx mix` / make build skipped, versioned filenames in public/dist out of sync with the Blade layout); (2) an uncaught exception earlier in compiled-editor-component or compiled-app aborted execution before tiptapController was assigned to the leantime namespace; (3) a CSP (InitialHeaders middleware sets CSP/X-Frame-Options) or browser extension blocked the script; (4) the required DOM ids were changed/removed by a template override so editorEl/textarea resolve null; (5) a slow connection had the script still loading when this inline block executed (no defer/load ordering guarantee).

Common situations: Deployments where git pulled new Blade templates but dist assets were not rebuilt (mismatched version hashes); local dev with `make build-dev` skipped; console shows a prior red error from a plugin or editor bundle; strict CSP environments; wiki templates customized by a theme that renamed wikiTiptapEditor/wikiArticleContent element ids.

Related errors


AI-assisted analysis of Leantime/leantime@9a9f49f100 (2026-08-21). Data as JSON: /api/errors/b6e343853039ceb7. Report an issue: GitHub.