{"record":{"id":"9835c18607671180","repo":"oven-sh/bun","slug":"could-not-parse-directive-value-directive-2-m","errorCode":null,"errorMessage":"Could not parse directive value ${directive[2]} (must be JSON parsable)","messagePattern":"Could not parse directive value (.+?) \\(must be JSON parsable\\)","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"src/codegen/bundle-functions.ts","lineNumber":188,"sourceCode":"      const i = result.indexOf(\"{\\n\");\n      // Support const enums in module scope.\n      topLevelEnums.push({\n        name: result.slice(\"const enum \".length, i).trim(),\n        code: \"\\n\" + result,\n      });\n\n      contents = rest;\n    } else if (match[1] === \"$\") {\n      const directive = contents.match(/^\\$([a-zA-Z0-9]+)(?:\\s*=\\s*([^\\r\\n]+?))?\\s*;?\\r?\\n/);\n      if (!directive) {\n        throw new SyntaxError(\"Could not parse directive:\\n\" + contents.slice(0, contents.indexOf(\"\\n\")));\n      }\n      const name = directive[1];\n      let value;\n      try {\n        value = directive[2] ? JSON.parse(directive[2]) : true;\n      } catch (error) {\n        throw new SyntaxError(\"Could not parse directive value \" + directive[2] + \" (must be JSON parsable)\");\n      }\n      if (name === \"constructor\") {\n        directives.ConstructAbility = \"CanConstruct\";\n      } else {\n        directives[name] = value;\n      }\n      contents = contents.slice(directive[0].length);\n    } else if (match[1] === \"export function\" || match[1] === \"export async function\") {\n      // consume async token and function name\n      const nameMatch = contents.match(/^export\\s+(async\\s+)?function\\s([_a-zA-Z0-9]+)\\s*/);\n      if (!nameMatch)\n        throw new SyntaxError(\"Could not parse function name:\\n\" + contents.slice(0, contents.indexOf(\"\\n\")));\n      const async = Boolean(nameMatch[1]);\n      const name = nameMatch[2];\n      var remaining = contents.slice(nameMatch[0].length);\n\n      // remove type parameters\n      if (remaining.startsWith(\"<\")) {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bundle-functions.ts#L170-L206","documentation":"Error \"Could not parse directive value ${directive[2]} (must be JSON parsable)\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/codegen/bundle-functions.ts:188 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}