{"record":{"id":"cd3700f09de8d5be","repo":"Meituan-Dianping/mpvue","slug":"injection-key-not-found","errorCode":null,"errorMessage":"Injection \"${key}\" not found","messagePattern":"Injection \"(.+?)\" not found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/weex-vue-framework/factory.js","lineNumber":3399,"sourceCode":"    // inject is :any because flow is not smart enough to figure out cached\n    var result = Object.create(null);\n    var keys = hasSymbol\n        ? Reflect.ownKeys(inject)\n        : Object.keys(inject);\n\n    for (var i = 0; i < keys.length; i++) {\n      var key = keys[i];\n      var provideKey = inject[key];\n      var source = vm;\n      while (source) {\n        if (source._provided && provideKey in source._provided) {\n          result[key] = source._provided[provideKey];\n          break\n        }\n        source = source.$parent;\n      }\n      if (process.env.NODE_ENV !== 'production' && !hasOwn(result, key)) {\n        warn((\"Injection \\\"\" + key + \"\\\" not found\"), vm);\n      }\n    }\n    return result\n  }\n}\n\n/*  */\n\nfunction createFunctionalComponent (\n  Ctor,\n  propsData,\n  data,\n  context,\n  children\n) {\n  var props = {};\n  var propOptions = Ctor.options.props;\n  if (isDef(propOptions)) {","sourceCodeStart":3381,"sourceCodeEnd":3417,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-vue-framework/factory.js#L3381-L3417","documentation":"Vue walks the ancestor chain looking for a matching key in each ancestor's `_provided` object when resolving `inject`. If no ancestor ever provided the requested key, Vue warns (dev only) and leaves the injected value `undefined`.","triggerScenarios":"A component declares `inject: ['foo']` (or `inject: { foo: ... }` with a non-optional default-less binding) but no ancestor in its chain calls `provide: { foo: ... }` or provides via a Symbol/unique key mismatch (e.g. `from: 'foo'` key mismatch).","commonSituations":"Component library consumers using a component outside its required provider (e.g. a `<checkbox-group>` child rendered without the group); renamed provide/inject keys after refactor; rendering the component in isolation in a test or story.","solutions":["Add `provide: { foo: ... }` on an appropriate ancestor component.","Declare a default: `inject: { foo: { default: fallbackValue } }` so the warning disappears and the component works standalone.","Use `inject: { foo: { from: 'actualProvidedKey' } }` if the key was renamed.","Make the binding explicitly optional with `default: undefined` if absence is legitimate."],"exampleFix":"// before\ninject: ['theme'];\n// after\ninject: { theme: { default: 'light' } }","handlingStrategy":"validation","validationCode":"// validate at setup/mount time\nif (this.$options.inject && !canInject('theme', this) && !('theme' in this)) {\n  console.warn('theme was not provided by any ancestor');\n}","typeGuard":"function hasInjection(vm, key) {\n  let s = vm.$parent;\n  while (s) { if (s._provided && s._provided[key] !== undefined) return true; s = s.$parent; }\n  return false;\n}","tryCatchPattern":null,"preventionTips":["Always declare inject with a `default:` so standalone usage is safe.","Keep provide/inject keys in shared constants to avoid typos.","Render provider-wrapped stories/tests when a component requires injection."],"tags":["vue","inject","provide","missing-dependency","dev-warning"],"backgroundTag":"injection-not-found","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}