{"record":{"id":"3e6b32699b000d5c","repo":"emberjs/ember.js","slug":"assertion-failed-desc","errorCode":null,"errorMessage":"Assertion Failed: ${desc}","messagePattern":"Assertion Failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@ember/debug/lib/assert.ts","lineNumber":54,"sourceCode":"    // Fail unconditionally\n    assert('This code path should never be run');\n    ```\n\n    @method assert\n    @static\n    @for @ember/debug\n    @param {String} description Describes the expectation. This will become the\n      text of the Error thrown if the assertion fails.\n    @param {any} condition Must be truthy for the assertion to pass. If\n      falsy, an exception will be thrown.\n    @public\n    @since 1.0.0\n  */\n  function assert(desc: string): never;\n  function assert(desc: string, test: unknown): asserts test;\n  function assert(desc: string, test?: unknown): asserts test {\n    if (!test) {\n      throw new Error(`Assertion Failed: ${desc}`);\n    }\n  }\n  setAssert(assert);\n}\n","sourceCodeStart":36,"sourceCodeEnd":59,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@ember/debug/lib/assert.ts#L36-L59","documentation":"Ember's assert() (from @ember/debug) throws an Error with the message 'Assertion Failed: <desc>' when its second argument is falsy. It is Ember's internal way to surface invariant violations in framework code and in apps during development.","triggerScenarios":"Any internal or app-level call to assert(desc, condition) where condition is falsy — e.g. assert('must have a model', this.model).","commonSituations":"Framework invariant violations during upgrade (removed/renamed APIs), passing undefined where a required value is expected, misconfigured initializers.","solutions":["Read the desc after 'Assertion Failed:' to identify the violated invariant","Fix the condition the assertion checks (supply the missing value / correct the call)","Search Ember source or the failing addon for the assert to understand the contract"],"exampleFix":"// before\nthis.set('controller', getOwner(this).lookup('controller:missing'));\n// after\nlet controller = getOwner(this).lookup('controller:missing');\nassert('Expected controller:missing to be registered', controller);\nthis.set('controller', controller);","handlingStrategy":"try-catch","validationCode":"// validate the invariant before the call that asserts it\nassert('model must be loaded', model != null);","typeGuard":"function hasModel(obj) { return obj != null && typeof obj === 'object'; }","tryCatchPattern":"try { riskyOperation(); } catch (e) { if (!/^Assertion Failed:/.test(e.message)) throw e; handleInvariantViolation(e.message.replace('Assertion Failed: ', '')); }","preventionTips":["Keep asserts enabled in test envs and fix the root cause, not the assert","Read the desc text to locate the violated contract","Supply required values before calling framework APIs","Pin framework versions and read deprecation guides when upgrading"],"tags":["ember","assertion","debug","invariant"],"backgroundTag":"assertion-failed","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}