{"record":{"id":"061ba6a5afc2eb80","repo":"ruvnet/ruflo","slug":"federation-canonicalization-rejects-typeof-value","errorCode":null,"errorMessage":"Federation canonicalization rejects ${typeof value}","messagePattern":"Federation canonicalization rejects (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugin-agent-federation/src/application/inbound-dispatcher.ts","lineNumber":162,"sourceCode":"\n  switch (typeof value) {\n    case 'boolean':\n      return value ? 'true' : 'false';\n    case 'string':\n      return JSON.stringify(value);\n    case 'number':\n      if (!Number.isFinite(value) || Object.is(value, -0)) {\n        throw new TypeError('Federation canonicalization rejects non-canonical numbers');\n      }\n      if (Number.isInteger(value) && !Number.isSafeInteger(value)) {\n        throw new TypeError('Federation canonicalization rejects unsafe integers');\n      }\n      return JSON.stringify(value);\n    case 'bigint':\n    case 'function':\n    case 'symbol':\n    case 'undefined':\n      throw new TypeError(`Federation canonicalization rejects ${typeof value}`);\n    case 'object':\n      break;\n    default:\n      throw new TypeError(`Federation canonicalization rejects ${typeof value}`);\n  }\n\n  const object = value as object;\n  if (ancestors.has(object)) {\n    throw new TypeError('Federation canonicalization rejects cyclic values');\n  }\n  ancestors.add(object);\n\n  try {\n    if (Array.isArray(value)) {\n      const items: string[] = [];\n      for (let index = 0; index < value.length; index += 1) {\n        if (!Object.prototype.hasOwnProperty.call(value, index)) {\n          throw new TypeError('Federation canonicalization rejects sparse arrays');","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugin-agent-federation/src/application/inbound-dispatcher.ts#L144-L180","documentation":"The JCS canonicalizer only handles JSON-representable values: bigint, function, symbol, and undefined all hit this rejection because they have no canonical JSON form and cannot participate in a deterministically signed payload. This is the explicit case list in the switch, distinct from the defensive default branch below it.","triggerScenarios":"BigInt IDs or counters stored in metadata (values from BigInt arithmetic); optional fields left as undefined instead of being omitted; property copies off class instances dragging function values along; Symbols used as enum-like keys with runtime values.","commonSituations":"Migrating numeric IDs to BigInt for range reasons; partial-object updates where absent fields stay undefined; objects built from class instances via spread.","solutions":["Omit undefined-valued keys instead of including them (build payloads via JSON round-trip or explicit deletion)","Convert BigInt with String(value) before placing it in the envelope","Ensure signed payloads originate from JSON.parse of received data or plain literals only","Add a deep scan before signing that rejects bigint/function/symbol/undefined anywhere in the tree"],"exampleFix":"// before\nmetadata.traceId = processBigintId(); // bigint\n// after\nmetadata.traceId = String(processBigintId());","handlingStrategy":"type-guard","validationCode":"// strip undefined keys and convert bigints before signing\nfunction toSignable<T>(value: T): T {\n  return JSON.parse(\n    JSON.stringify(value, (_k, v) => (typeof v === 'bigint' ? String(v) : v)),\n  );\n}","typeGuard":"function isCanonicalValueKind(v: unknown): boolean {\n  const t = typeof v;\n  return (\n    t === 'string' ||\n    t === 'number' ||\n    t === 'boolean' ||\n    (t === 'object' && v !== null)\n  );\n}","tryCatchPattern":null,"preventionTips":["Omit undefined-valued keys instead of including them","Stringify BigInt at the boundary where it is created","Build signed payloads from JSON.parse output or plain literals","Spread-copy class instances into POJOs, not the instances themselves"],"tags":["canonicalization","jcs","bigint","types"],"backgroundTag":"unsupported-serialization-type","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}