{"record":{"id":"46404fac50427b14","repo":"ruvnet/ruflo","slug":"msgtype-must-be-alnum-and-64-chars","errorCode":null,"errorMessage":"msgType must be alnum + _ - and ≤64 chars","messagePattern":"msgType must be alnum \\+ _ - and ≤64 chars","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/mcp-tools/agentbbs-tools.ts","lineNumber":400,"sourceCode":"        },\n        payload: {\n          type: 'object',\n          description: 'Event-specific JSON-serializable payload.',\n        },\n        signature: {\n          type: 'string',\n          description: 'Optional Ed25519 signature over the canonical envelope bytes. Phase 1: pass-through.',\n        },\n      },\n      required: ['roomId', 'msgType', 'payload'],\n    },\n    handler: async (input) => {\n      const basePath = resolveBasePath(input.basePath as string | undefined);\n      const roomId = validateRoomId(String(input.roomId));\n      const msgType = String(input.msgType ?? '');\n      if (!msgType) throw new Error('msgType is required');\n      if (msgType.length > 64 || !/^[A-Za-z0-9_-]+$/.test(msgType)) {\n        throw new Error('msgType must be alnum + _ - and ≤64 chars');\n      }\n      if (typeof input.payload !== 'object' || input.payload === null) {\n        throw new Error('payload must be a JSON object');\n      }\n\n      if (!agentbbsCliAvailable()) return degradedResult('agentbbs-not-found');\n\n      ensureDir(basePath);\n      const logPath = roomLogPath(basePath, roomId);\n      const base: BbsEnvelope = {\n        envelopeId: base64url(randomBytes(12)),\n        roomId,\n        seq: nextSeq(logPath),\n        msgType,\n        payload: input.payload,\n        timestamp: new Date().toISOString(),\n      };\n      // Phase 2: sign with this host's persistent node identity so peers can","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/ruvnet/ruflo/blob/9c61c86f06b439af2a95085ae9bb0ca839662e41/v3/@claude-flow/cli/src/mcp-tools/agentbbs-tools.ts#L382-L418","documentation":"The agentbbs post handler validates msgType against ^[A-Za-z0-9_-]+$ with a 64-character cap — stricter than roomLabel (no dots, colons, slashes, '#', or '@'). Dotted types like 'chat.message' are therefore REJECTED despite reading naturally; use 'chat_message' instead. The strict format keeps envelope routing/dispatch unambiguous.","triggerScenarios":"Passing 'chat.message' (dot), 'user/mention' (slash), 'a b' (space), '#announce' ('#'), or any type longer than 64 chars; migrating message schemas from systems that use dotted or URI-style type names.","commonSituations":"Teams standardizing on namespaced dotted event names (activitystrea.ms style) hitting the charset rule; long fully-qualified type names exceeding 64 chars.","solutions":["Use snake/kebab types within the charset: 'chat_message', 'task-update' — replace '.' with '_'","Trim overlong names to ≤64 chars and prefer short vocabularies ('note', 'alert', 'assign')","Validate at the caller with the same regex /^[A-Za-z0-9_-]+$/ and length check for an early error"],"exampleFix":"// before — dot not allowed\nawait callMCPTool('agentbbs_post', { roomId, msgType: 'chat.message', payload });\n\n// after — underscore form\nawait callMCPTool('agentbbs_post', { roomId, msgType: 'chat_message', payload });","handlingStrategy":"validation","validationCode":"const MSG_TYPE_RE = /^[A-Za-z0-9_-]+$/;\n\nfunction normalizeMsgType(raw: string): string {\n  const t = raw.replace(/[.:/@#\\s]+/g, '_').replace(/[^A-Za-z0-9_-]/g, '');\n  if (t.length === 0 || t.length > 64 || !MSG_TYPE_RE.test(t)) {\n    throw new Error(`cannot normalize msgType: ${raw}`);\n  }\n  return t;\n}","typeGuard":"const isValidMsgType = (v: string): boolean => /^[A-Za-z0-9_-]+$/.test(v) && v.length <= 64 && v.length > 0;","tryCatchPattern":null,"preventionTips":["Standardize on snake_case msgTypes — dots, slashes, and '#' are not accepted (stricter than roomLabel)","Keep the type vocabulary short (≤64 chars)","Map external dotted event names to underscores at your boundary"],"tags":["validation","agentbbs","charset","messaging","format"],"backgroundTag":"invalid-format","analyzedSha":"9c61c86f06b439af2a95085ae9bb0ca839662e41","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}