{"record":{"id":"c395d28ca91bf1aa","repo":"krisk/Fuse","slug":"property-weight-in-key-key-must-be-a-positi","errorCode":null,"errorMessage":"Property 'weight' in key '${key}' must be a positive integer","messagePattern":"Property 'weight' in key '(.+?)' must be a positive integer","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/tools/KeyStore.ts","lineNumber":67,"sourceCode":"    | null = null\n\n  if (isString(key) || isArray(key)) {\n    src = key\n    path = createKeyPath(key)\n    id = createKeyId(key)\n  } else {\n    if (!hasOwn.call(key, 'name')) {\n      throw new Error(ErrorMsg.MISSING_KEY_PROPERTY('name'))\n    }\n\n    const name = key.name\n    src = name\n\n    if (hasOwn.call(key, 'weight') && key.weight !== undefined) {\n      weight = key.weight\n\n      if (weight <= 0) {\n        throw new Error(ErrorMsg.INVALID_KEY_WEIGHT_VALUE(createKeyId(name)))\n      }\n    }\n\n    path = createKeyPath(name)\n    id = createKeyId(name)\n    getFn = key.getFn ?? null\n  }\n\n  return { path: path!, id: id!, weight, src: src!, getFn }\n}\n\nexport function createKeyPath(key: string | string[]): string[] {\n  return isArray(key) ? key : key.split('.')\n}\n\nexport function createKeyId(key: string | string[]): string {\n  return isArray(key) ? key.join('.') : key\n}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/krisk/Fuse/blob/edf2fb608eca0461508d1d71317e6e58309ffada/src/tools/KeyStore.ts#L49-L85","documentation":"Thrown by createKey when an object-form key declares a 'weight' (other than undefined) whose value is <= 0. Weights scale per-key scores and must be positive; a zero or negative weight would either zero out the field's contribution entirely or invert score ordering, so it is rejected at key normalization time.","triggerScenarios":"Thrown at src/tools/KeyStore.ts:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give the key a positive integer weight, e.g. { name: 'title', weight: 20 }","Remove the 'weight' property (or set it to undefined) to use the default weight of 1","Fix the computation that produced the weight — dynamic weights derived from division or subtraction can yield 0 or negatives"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"edf2fb608eca0461508d1d71317e6e58309ffada","analyzedAt":"2026-09-02T02:46:54.623Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}