{"record":{"id":"236bb66792de71f2","repo":"emberjs/ember.js","slug":"more-context-objects-were-passed-than-there-are-dy","errorCode":null,"errorMessage":"More context objects were passed than there are dynamic segments for the route: ${targetRouteName}","messagePattern":"More context objects were passed than there are dynamic segments for the route: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/router_js/lib/transition-intent/named-transition-intent.ts","lineNumber":142,"sourceCode":"\n      if (i >= invalidateIndex || newHandlerInfo.shouldSupersede(oldHandlerInfo)) {\n        invalidateIndex = Math.min(i, invalidateIndex);\n        handlerToUse = newHandlerInfo;\n      }\n\n      if (isIntermediate && !checkingIfActive) {\n        handlerToUse = handlerToUse.becomeResolved(\n          null,\n          // SAFETY: This seems to imply that it would be resolved, but it's unclear if that's actually the case.\n          handlerToUse.context as ModelFor<R>\n        );\n      }\n\n      newState.routeInfos.unshift(handlerToUse);\n    }\n\n    if (objects.length > 0) {\n      throw new Error(\n        'More context objects were passed than there are dynamic segments for the route: ' +\n          targetRouteName\n      );\n    }\n\n    if (!isIntermediate) {\n      this.invalidateChildren(newState.routeInfos, invalidateIndex);\n    }\n\n    merge(newState.queryParams, this.queryParams || {});\n    if (isIntermediate && oldState.queryParams) {\n      merge(newState.queryParams, oldState.queryParams);\n    }\n\n    return newState;\n  }\n\n  invalidateChildren(handlerInfos: InternalRouteInfo<R>[], invalidateIndex: number) {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/router_js/lib/transition-intent/named-transition-intent.ts#L124-L160","documentation":"router_js throws this from NamedTransitionIntent.applyToHandlers when a transition like transitionTo('post', post, comment, extra) supplies more context objects than the target route chain has dynamic segments. Extra contexts cannot be attached to any route, so the intent is rejected rather than silently dropping them.","triggerScenarios":"route.transitionTo('routeName', ctx1, ctx2, ...) or {{link-to}} with more positional models/objects than the sum of dynamic segments (:id etc.) across the matched routes.","commonSituations":"Passing (model, queryParam-ish extra arg) by mistake to transitionTo; refactoring a route to drop a nested dynamic segment while callers still pass two contexts; accidentally passing a second argument like options object positionally.","solutions":["Count the dynamic segments on the target route chain and pass exactly that many context objects.","If an extra argument is metadata, pass it as a second argument after a queryParams object or via route options, not as a context.","Update stale transitionTo/link-to call sites after removing nested resources.","For optional data, use a service or queryParams instead of an extra positional context."],"exampleFix":"// before\nthis.transitionTo('post.comments', post, comment, sortBy);\n// after\nthis.transitionTo('post.comments', post, comment, { queryParams: { sort: sortBy } });","handlingStrategy":"validation","validationCode":"const dynamicSegments = countDynamicSegments(routeName); // parse router map e.g. /posts/:post_id/comments/:comment_id\nif (contexts.length > dynamicSegments) throw new Error(`Pass only ${dynamicSegments} contexts to ${routeName}`);","typeGuard":"null","tryCatchPattern":"try { router.transitionTo('post.comments', post, comment); }\ncatch (e) { if (e.message.startsWith('More context objects')) { console.error('extra context passed:', e); } else throw e; }","preventionTips":["Match transitionTo/link-to args 1:1 with dynamic segments in router map.","Never pass options objects positionally; use queryParams argument.","Audit call sites after removing/renaming nested routes.","Use link-to components with models instead of manual transitions where possible."],"tags":["routing","ember","router"],"backgroundTag":"too-many-route-contexts","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}