{"record":{"id":"b6e343853039ceb7","repo":"Leantime/leantime","slug":"migration-failed-see-below","errorCode":null,"errorMessage":"Migration Failed; See below","messagePattern":"Migration Failed; See below","errorType":"console","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"app/Command/MigrateCommand.php","lineNumber":121,"sourceCode":"                if ($getAdminUser !== false && is_array($getAdminUser)) {\n                    $userId = $getAdminUser['id'];\n                    $usersRepo->patchUser($userId, ['password' => $setupConfig['password'], 'status' => 'a']);\n\n                    $helperService = app()->make(Helper::class);\n                    $helperService->createDefaultProject($userId, 'owner');\n                }\n\n                if ($silent) {\n                    $usersRepo = app()->make(Users::class);\n                    $userId = array_values($usersRepo->getUserByEmail($adminEmail))[0];\n                    $usersRepo->deleteUser($userId);\n                }\n\n                $io->text('Successfully Installed DB');\n            }\n            $success = $install->updateDB();\n            if ($success !== true) {\n                throw new Exception('Migration Failed; See below'.PHP_EOL.implode(PHP_EOL, $success));\n            }\n        } catch (Exception $ex) {\n            $io->error($ex);\n\n            return Command::FAILURE;\n        }\n\n        $io->success('Database Successfully Migrated');\n\n        return Command::SUCCESS;\n    }\n}\n","sourceCodeStart":103,"sourceCodeEnd":134,"githubUrl":"https://github.com/Leantime/leantime/blob/9a9f49f1008f4782b30f6723c54228f4f992e636/app/Command/MigrateCommand.php#L103-L134","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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.","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.","Verify the DOM contract: the page must contain #wikiDocumentWrapper, #wikiTiptapEditor and #wikiArticleContent — restore them if a theme/child template renamed them.","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.","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."],"exampleFix":"// before — bails silently for editors if the bundle is late or missing\nif (!editorEl || !textarea || !window.leantime || !window.leantime.tiptapController) {\n    console.warn('[Wiki] Tiptap controller not available');\n    return;\n}\n\n// after — wait for the bundle on DOMContentLoaded/window load before giving up, and surface the fallback\nfunction initWikiTiptap() {\n    if (!window.leantime || !window.leantime.tiptapController) {\n        console.warn('[Wiki] Tiptap controller not available — falling back to plain textarea');\n        var ta = document.getElementById('wikiArticleContent');\n        if (ta) ta.style.display = '';\n        return;\n    }\n    /* existing wiring */\n}\nif (document.readyState === 'complete') initWikiTiptap();\nelse window.addEventListener('load', initWikiTiptap);","handlingStrategy":"type-guard","validationCode":"// Page-level smoke check (dev console or e2e test) before relying on the editor\nconst ready =\n    document.getElementById('wikiTiptapEditor') instanceof HTMLElement &&\n    document.getElementById('wikiArticleContent') instanceof HTMLTextAreaElement &&\n    typeof window.leantime?.tiptapController?.attach === 'function';\nif (!ready) console.warn('[Wiki] Tiptap prerequisites missing — check editor bundle and element ids');","typeGuard":"function tiptapAvailable() {\n    return typeof window === 'object'\n        && window.leantime instanceof Object\n        && 'tiptapController' in window.leantime\n        && typeof window.leantime.tiptapController === 'object';\n}\n\n(function initWikiEditor() {\n    if (!tiptapAvailable()) {\n        console.warn('[Wiki] Tiptap controller not available');\n        const ta = document.getElementById('wikiArticleContent');\n        if (ta) ta.hidden = false; // explicit textarea fallback instead of a dead editor area\n        return;\n    }\n    // ... existing tiptap wiring\n})();","tryCatchPattern":null,"preventionTips":["Treat asset builds as part of deploy: run `make build` whenever Blade templates change, and verify the versioned filenames referenced by the layout exist in public/dist.","Load the editor bundle before the wiki inline script (defer order or window load hook) so the controller check does not race the bundle.","Watch for earlier console errors first — a single uncaught exception in a global bundle un-registers every controller after it.","Preserve the DOM contract ids (wikiTiptapEditor, wikiArticleContent, wikiDocumentWrapper) across theme overrides, and assert them in an e2e test."],"tags":["javascript","editor","wiki","asset-build","frontend"],"backgroundTag":"javascript-controller-not-registered","analyzedSha":"9a9f49f1008f4782b30f6723c54228f4f992e636","analyzedAt":"2026-08-21T02:37:38.966Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}