{"record":{"id":"77df0d4b274ca4b1","repo":"qishibo/AnotherRedisDesktopManager","slug":"something-wrong-with-your-vector","errorCode":null,"errorMessage":"Something wrong with your vector","messagePattern":"Something wrong with your vector","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/components/contents/KeyContentVector.vue","lineNumber":484,"sourceCode":"    },\n    runSimilarity() {\n      const { client, redisKey } = this;\n      const count = this.simCount;\n      let args;\n\n      // search by element name\n      if (this.simMode === 'ele') {\n        const element = (this.simElement || '').trim();\n        if (!element) {\n          return this.$message.error('Element is required');\n        }\n        args = ['VSIM', redisKey, 'ELE', element, 'WITHSCORES', 'WITHATTRIBS', 'COUNT', count];\n      }\n      // search by vector\n      else {\n        const vector = this.parseVectorText(this.simVectorText);\n        if (!vector) {\n          return this.$message.error('Something wrong with your vector');\n        }\n        if (this.dim && vector.length !== this.dim) {\n          return this.$message.error(`Vector dimension must be ${this.dim}`);\n        }\n        args = ['VSIM', redisKey, 'VALUES', vector.length, ...vector, 'WITHSCORES', 'WITHATTRIBS', 'COUNT', count];\n      }\n\n      this.simLoading = true;\n\n      client.call(...args).then((reply) => {\n        this.simResults = this.parseSimReply(reply);\n        this.simLoading = false;\n      }).catch((e) => {\n        this.simLoading = false;\n        this.$message.error(e.message);\n      });\n    },\n    parseSimReply(reply) {","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/qishibo/AnotherRedisDesktopManager/blob/c149855106628babcdfb7675a8e7ba9434d2492a/src/components/contents/KeyContentVector.vue#L466-L502","documentation":"Client-side validation in the similarity dialog's 'vector' mode. parseVectorText (KeyContentVector.vue:315) splits this.simVectorText on commas, trims each token, and maps it through Number(); it returns null when the text is blank or when any token is not a finite number (NaN, Infinity, empty token from a trailing/double comma). runSimilarity() aborts with this toast before any Redis call when the parse yields null.","triggerScenarios":"Calling VSIM in VALUES mode with simVectorText that is (a) empty/whitespace-only, (b) space-separated instead of comma-separated numbers like '0.1 0.2 0.3', (c) contains a non-numeric token such as 'abc' or 'null', or (d) has a trailing/doubled comma producing an empty token ('0.1,0.2,').","commonSituations":"Copying an embedding from Python (repr uses spaces: [0.1, 0.2] sometimes survives but NumPy array str '[-0.01130762  0.04266454 ...]' fails because tokens are space-separated); pasting JSON array text with brackets '[' ']'; pasting scientific notation is fine but '1e' or '--1' is not; empty clipboard paste.","solutions":["Reformat the vector as comma-separated bare numbers, e.g. 0.1,0.2,0.3 — no brackets, no quotes","If pasting from Python/NumPy, strip brackets and convert: ','.join(map(str, vec)) or str(vec.tolist())","Check for trailing commas, double commas, semicolons, or localized decimal separators (0,1 instead of 0.1) — all produce NaN tokens","Verify no stray characters (quotes, 'tensor(...)', dtype suffix) remain after pasting"],"exampleFix":"// before: only comma-separated input parses\nparseVectorText(text) {\n  if (!text.trim()) return null;\n  const vector = text.split(',').map(v => Number(v.trim()));\n  if (!vector.length || vector.some(n => !Number.isFinite(n))) return null;\n  return vector;\n}\n\n// after: also accept whitespace/bracket-separated pastes\nparseVectorText(text) {\n  if (!text) return null;\n  const cleaned = text.replace(/[\\[\\]()]/g, '');\n  const vector = cleaned.split(/[\\s,;]+/).filter(t => t.length).map(Number);\n  if (!vector.length || vector.some(n => !Number.isFinite(n))) return null;\n  return vector;\n}","handlingStrategy":"validation","validationCode":"// validate before issuing VSIM VALUES\nconst vector = this.parseVectorText(this.simVectorText);\nif (!vector) {\n  // tell the user WHY: empty vs non-numeric tokens\n  const tokens = this.simVectorText.split(',').map(s => s.trim()).filter(Boolean);\n  const bad = tokens.filter(t => !Number.isFinite(Number(t)));\n  this.vectorError = bad.length ? `Non-numeric component: ${bad[0]}` : 'Vector is empty';\n  return;\n}","typeGuard":"/** True when text parses to a finite-number vector of the expected length. */\nfunction isParsableVector(text, dim) {\n  if (!text || !text.trim()) return false;\n  const parts = text.split(',').map(s => Number(s.trim()));\n  return parts.length > 0 && parts.every(n => Number.isFinite(n)) && (!dim || parts.length === dim);\n}","tryCatchPattern":"null","preventionTips":["Normalize pasted embeddings before entering the dialog: strip brackets/quotes and join with commas","Show a live parse preview (component count + first invalid token) under the textarea instead of failing on submit","Accept whitespace-separated input in parseVectorText, since most tools print vectors space-separated"],"tags":["redis","vector-set","vsim","input-parsing","validation","embedding","vue"],"backgroundTag":"invalid-input-format","analyzedSha":"c149855106628babcdfb7675a8e7ba9434d2492a","analyzedAt":"2026-08-22T09:06:28.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}