{"record":{"id":"013799b1e1f01250","repo":"qishibo/AnotherRedisDesktopManager","slug":"select-a-correct-type-to-encode","errorCode":null,"errorMessage":"Select a correct Type to encode","messagePattern":"Select a correct Type to encode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/components/viewers/ViewerProtobuf.vue","lineNumber":99,"sourceCode":"\n      return this.proto.map(p => path.basename(p || '')).join(', ');\n    },\n    keyHex() {\n      return this.redisKey.toString('hex');\n    },\n  },\n  mounted() {\n    this.restoreBinding();\n  },\n  methods: {\n    getContent() {\n      if (!this.protoRoot) {\n        this.$message.error('Select a correct .proto file');\n        return false;\n      }\n\n      if (!this.selectedType || this.selectedType === 'Rawproto') {\n        this.$message.error('Select a correct Type to encode');\n        return false;\n      }\n\n      let content = this.$refs.editor.getRawContent();\n      const type = this.protoRoot.lookupType(this.selectedType);\n\n      try {\n        content = JSON.parse(content);\n      } catch (e) {\n        this.$message.error(this.$t('message.json_format_failed'));\n        return false;\n      }\n\n      // toJSON() shows int64/uint64 as strings; fromObject converts them back\n      const message = type.fromObject(content);\n      const err = type.verify(message);\n      if (err) {\n        this.$message.error(`Proto Verify Failed: ${err}`);","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/qishibo/AnotherRedisDesktopManager/blob/c149855106628babcdfb7675a8e7ba9434d2492a/src/components/viewers/ViewerProtobuf.vue#L81-L117","documentation":"Element UI toast shown when the protobuf viewer's getContent() runs with no selected message type, or with the sentinel value 'Rawproto' still selected. this.selectedType is populated by traversing the loaded protobuf.Root (traverseTypes collects protobuf.Type full names); 'Rawproto' means the app is displaying the raw protobuf dump instead of decoding through a schema, which cannot be used to re-encode typed content.","triggerScenarios":"Loading a key whose content failed schema decode, causing the type dropdown to stay on 'Rawproto'; selecting an empty option in the type el-select; opening a key bound to a .proto that declares no message types; submitting before choosing a type after loading the proto files.","commonSituations":"The chosen .proto compiles but declares only enums/services with no message; the decode step failed earlier and silently left selectedType unset; the user assumes the previous key's type selection persists across keys.","solutions":["Pick a concrete message type (not Rawproto) from the type dropdown above the editor, then save","If only Rawproto appears, the loaded .proto declares no message types — check it exports a message and reselect the file","Ensure the earlier decode succeeded; a failed decode leaves the viewer in raw mode"],"exampleFix":"// before\nif (!this.selectedType || this.selectedType === 'Rawproto') {\n  this.$message.error('Select a correct Type to encode');\n  return false;\n}\n\n// after - same guard, plus disable save in the template\n<el-select v-model=\"selectedType\" :disabled=\"!protoRoot\">...</el-select>\n<el-button :disabled=\"!protoRoot || !selectedType || selectedType === 'Rawproto'\" @click=\"save\">Save</el-button>","handlingStrategy":"validation","validationCode":"const t = this.selectedType;\nif (!t || t === 'Rawproto') {\n  this.$message.error('Select a correct Type to encode');\n  return false;\n}","typeGuard":"const isEncodableType = (t) => Boolean(t) && t !== 'Rawproto';","tryCatchPattern":null,"preventionTips":["Default selectedType to the first message type after a successful proto load","Disable save when the dropdown shows Rawproto","Verify the .proto declares at least one message before enabling the type selector"],"tags":["protobuf","ui-validation","vue","type-selection"],"backgroundTag":"missing-schema-type","analyzedSha":"c149855106628babcdfb7675a8e7ba9434d2492a","analyzedAt":"2026-08-22T09:06:28.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}