{"record":{"id":"3e7e1091e5a285d4","repo":"vuejs/vuex","slug":"vuex-msg","errorCode":null,"errorMessage":"[vuex] ${msg}","messagePattern":"\\[vuex\\] (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/util.js","lineNumber":65,"sourceCode":"}\n\n/**\n * forEach for object\n */\nexport function forEachValue (obj, fn) {\n  Object.keys(obj).forEach(key => fn(obj[key], key))\n}\n\nexport function isObject (obj) {\n  return obj !== null && typeof obj === 'object'\n}\n\nexport function isPromise (val) {\n  return val && typeof val.then === 'function'\n}\n\nexport function assert (condition, msg) {\n  if (!condition) throw new Error(`[vuex] ${msg}`)\n}\n\nexport function partial (fn, arg) {\n  return function () {\n    return fn(arg)\n  }\n}\n","sourceCodeStart":47,"sourceCodeEnd":73,"githubUrl":"https://github.com/vuejs/vuex/blob/bd907467b8392d6671bb115738285ff7f63d0cf6/src/util.js#L47-L73","documentation":"assert is Vuex's internal assertion helper: any failed condition during store setup or API misuse throws with a '[vuex]' prefix. Callers use it to validate raw module options, state access under strict mode, action/mutation argument shape (unifyObjectStyle), etc.","triggerScenarios":"commit/dispatch called with an object lacking a valid 'type' (unifyObjectStyle assert); store state accessed before store finished construction; module registered with wrong 'rawModule' shape (assertRawModule); watch with invalid options; strict mode violations in enableStrictMode.","commonSituations":"Typo like commit({ type: 'increment' }) vs commit('increment'); passing a plain string where a function was expected; Vuex 3 vs Vuex 4 option mismatches; third-party plugins calling internal APIs incorrectly.","solutions":["Read the '[vuex] ...' message — it names the exact failed condition","Ensure commit/dispatch are called as commit('type', payload) or commit({ type }, payload)","Validate module option objects (state as function, namespaced boolean, etc.) before registerModule","Check Vuex version compatibility of plugins"],"exampleFix":"// before\nstore.commit({}) // missing type -> assert fails\n// after\nstore.commit({ type: 'increment' })","handlingStrategy":"validation","validationCode":"function isValidCommitArg(arg) {\n  return typeof arg === 'string' || (arg && typeof arg === 'object' && typeof arg.type === 'string' && arg.type.length > 0)\n}\n// call sites: if (!isValidCommitArg(t)) throw new TypeError('commit requires a type')","typeGuard":"function isCommitObject(v) {\n  return typeof v === 'object' && v !== null && typeof v.type === 'string'\n}","tryCatchPattern":"try {\n  store.commit(payload)\n} catch (e) {\n  if (String(e.message).startsWith('[vuex]')) { console.error('Vuex API misuse:', e.message) }\n  else throw e\n}","preventionTips":["Always pass an explicit type string to commit/dispatch","Pin Vuex major version and read its migration guide when upgrading","Validate module option objects before registerModule in tests","Run unit tests with __DEV__ assertions enabled to catch misuse early"],"tags":["vuex","assertion","api-misuse"],"backgroundTag":"assertion-failed","analyzedSha":"bd907467b8392d6671bb115738285ff7f63d0cf6","analyzedAt":"2026-08-28T21:38:57.320Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}