{"record":{"id":"de23d8574310c6db","repo":"saadeghi/daisyui","slug":"html-must-be-a-string","errorCode":null,"errorMessage":"html must be a string","messagePattern":"html must be a string","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwind-play-share/index.mjs","lineNumber":167,"sourceCode":"  if (html === undefined && css === undefined && !process.stdin.isTTY) {\n    const stdin = (await readStdin()).trim()\n    if (stdin) {\n      let parsed\n      try {\n        parsed = JSON.parse(stdin)\n      } catch (error) {\n        throw new Error(`stdin must be JSON with html and css strings: ${error.message}`)\n      }\n      html = parsed.html\n      css = parsed.css\n    }\n  }\n\n  if (html === undefined && css === undefined) {\n    throw new Error(\"Provide HTML/CSS using arguments, files, or JSON on stdin\")\n  }\n  if (html !== undefined && typeof html !== \"string\") {\n    throw new Error(\"html must be a string\")\n  }\n  if (css !== undefined && typeof css !== \"string\") {\n    throw new Error(\"css must be a string\")\n  }\n\n  return { html: html ?? \"\", css: css ?? \"\" }\n}\n\nasync function isExecutable(filePath) {\n  try {\n    await access(filePath, process.platform === \"win32\" ? fsConstants.F_OK : fsConstants.X_OK)\n    return true\n  } catch {\n    return false\n  }\n}\n\nasync function resolveExecutable(candidate) {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/saadeghi/daisyui/blob/42b09e637e09467aa54a813a5aea53c1179aec75/packages/tailwind-play-share/index.mjs#L149-L185","documentation":"After resolving, if html is defined (not undefined) but typeof html is not 'string', the script throws. This catches malformed JSON where the html field is a number, array, object, or null (null is not undefined, so it triggers this branch).","triggerScenarios":"Piping JSON like `{\"html\":123}`, `{\"html\":[\"...\"]}`, `{\"html\":{\"raw\":\"...\"}}`, or `{\"html\":null}`.","commonSituations":"A programmatic producer emits the wrong type; a YAML-to-JSON conversion yields a non-string; null used to mean 'absent'.","solutions":["Ensure the html field is a JSON string.","Omit the html key entirely if you have no HTML (so it stays undefined).","Coerce to string in your producer before serializing."],"exampleFix":"# before\necho '{\"html\":[\"<div/>\"]}' | bun .../index.mjs\n# after\necho '{\"html\":\"<div/>\"}' | bun .../index.mjs","handlingStrategy":"type-guard","validationCode":"if (html !== undefined && typeof html !== 'string') {\n  throw new Error('html must be a string')\n}","typeGuard":"const isOptionalString = (v) => v === undefined || typeof v === 'string'","tryCatchPattern":null,"preventionTips":["Serialise html as a JSON string in your producer.","Omit the html key rather than passing null when you have none.","Validate the JSON shape with a schema before piping."],"tags":["cli","stdin","json","validation","type"],"backgroundTag":null,"analyzedSha":"42b09e637e09467aa54a813a5aea53c1179aec75","analyzedAt":"2026-08-13T04:10:09.555Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}