{"record":{"id":"0d56bee7da4d034d","repo":"qishibo/AnotherRedisDesktopManager","slug":"attributes-must-be-valid-json","errorCode":null,"errorMessage":"Attributes must be valid JSON","messagePattern":"Attributes must be valid JSON","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/components/contents/KeyContentVector.vue","lineNumber":361,"sourceCode":"      }\n    },\n    editLine() {\n      const before = this.beforeEditItem;\n      const element = (this.editLineItem.element || '').trim();\n      const vector = this.parseVectorText(this.editLineItem.vectorText);\n      const attrs = (this.editLineItem.attrs || '').trim();\n\n      if (!element) {\n        return this.$message.error('Element is required');\n      }\n      if (!vector || !vector.length) {\n        return this.$message.error('Vector is required');\n      }\n      if (this.dim && vector.length !== this.dim) {\n        return this.$message.error(`Vector dimension must be ${this.dim}`);\n      }\n      if (attrs && !this.$util.isJson(attrs)) {\n        return this.$message.error('Attributes must be valid JSON');\n      }\n\n      this.editDialog = false;\n\n      const vaddArgs = [this.redisKey, 'VALUES', vector.length, ...vector, element];\n      // must match existing set quant-type, otherwise: ERR asked quantization mismatch\n      const quantOpt = this.getQuantOption();\n      quantOpt && vaddArgs.push(quantOpt);\n\n      // set attributes\n      attrs && vaddArgs.push('SETATTR', attrs);\n\n      this.client.call('VADD', ...vaddArgs).then(() => {\n        if (this.isEdit) {\n          this.$message.success({ message: this.$t('message.modify_success'), duration: 1000 });\n        } else {\n          this.vectorData.push({ element });\n          this.total++;","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/qishibo/AnotherRedisDesktopManager/blob/c149855106628babcdfb7675a8e7ba9434d2492a/src/components/contents/KeyContentVector.vue#L343-L379","documentation":"The optional attributes field failed the isJson check, so VADD ... SETATTR is never sent. SETATTR expects a JSON object; the client refuses malformed JSON client-side, mirroring error 103 but for the attribute box.","triggerScenarios":"Single-quoted keys, unquoted keys, trailing commas in the attributes box; a half-edited object; pasting Python dict syntax.","commonSituations":"Metadata pasted from Python dicts or YAML; quick edits leaving a dangling comma.","solutions":["Use strict JSON: double-quoted keys and string values, no trailing commas","Validate the attributes in a JSON linter before saving"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (attrs && !isJson(attrs)) {\n  return this.$message.error('Attributes must be valid JSON');\n}\n\nfunction isJson(str) {\n  try { JSON.parse(str); return true; } catch (_) { return false; }\n}","typeGuard":"function isJsonObject(str) {\n  if (typeof str !== 'string' || !str.trim()) return false;\n  try { const v = JSON.parse(str); return v !== null && typeof v === 'object' && !Array.isArray(v); } catch (_) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Validate optional JSON fields exactly like required ones — an empty value is fine, a malformed one is not","Lint attributes with JSON.parse and show the parse position on failure","Accept only objects for SETATTR to match Redis expectations"],"tags":["validation","json","vector-sets","form"],"backgroundTag":"json-parse-error","analyzedSha":"c149855106628babcdfb7675a8e7ba9434d2492a","analyzedAt":"2026-08-22T09:06:28.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}