{"record":{"id":"9228656f0f59eda2","repo":"ruvnet/ruflo","slug":"jcs-canonicalization-accepts-only-json-compatible","errorCode":null,"errorMessage":"JCS canonicalization accepts only JSON-compatible plain objects","messagePattern":"JCS canonicalization accepts only JSON-compatible plain objects","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/security/src/policy/product-plane.ts","lineNumber":1112,"sourceCode":"    assertUnicodeScalarString(value);\n    return JSON.stringify(value);\n  }\n  if (typeof value === 'number') {\n    if (!Number.isFinite(value)) throw new TypeError('JCS canonicalization rejects non-finite numbers');\n    return JSON.stringify(value);\n  }\n  if (Array.isArray(value)) {\n    const items: string[] = [];\n    for (let index = 0; index < value.length; index++) {\n      if (!Object.prototype.hasOwnProperty.call(value, index)) {\n        throw new TypeError('JCS canonicalization rejects sparse arrays');\n      }\n      items.push(canonicalizeProductPlane(value[index]));\n    }\n    return `[${items.join(',')}]`;\n  }\n  if (!isRecord(value)) {\n    throw new TypeError('JCS canonicalization accepts only JSON-compatible plain objects');\n  }\n  const entries: string[] = [];\n  for (const key of Object.keys(value).sort()) {\n    assertUnicodeScalarString(key);\n    if (value[key] === undefined) {\n      throw new TypeError('JCS canonicalization rejects undefined object values');\n    }\n    entries.push(`${JSON.stringify(key)}:${canonicalizeProductPlane(value[key])}`);\n  }\n  return `{${entries.join(',')}}`;\n}\n\nexport function canonicalProductPlaneBytes(value: unknown): Uint8Array {\n  return Buffer.from(canonicalizeProductPlane(value), 'utf8');\n}\n\nexport function canonicalProductPlaneDigest(value: unknown): `sha256:${string}` {\n  return `sha256:${createHash('sha256').update(canonicalProductPlaneBytes(value)).digest('hex')}`;","sourceCodeStart":1094,"sourceCodeEnd":1130,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/security/src/policy/product-plane.ts#L1094-L1130","documentation":"JCS canonicalizer guard: the value being serialized is neither a primitive nor an array nor a plain object (isRecord failed) — e.g. a Date, Map, class instance, or null-prototype object. JCS only defines canonical forms for JSON-compatible plain objects, so such values are rejected rather than coerced.","triggerScenarios":"Thrown at v3/@claude-flow/security/src/policy/product-plane.ts:1112 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Strip class instances, Maps, Sets, and functions before canonicalizing; convert them to plain JSON objects first.","Use a serializer (e.g. JSON.parse(JSON.stringify(value)) with a replacer) to normalize non-plain objects into JSON-compatible shapes."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}