{"record":{"id":"332ce4bb78124e0b","repo":"santifer/career-ops","slug":"the-release-pointer-is-not-an-object-url","errorCode":null,"errorMessage":"the release pointer is not an object: ${url}","messagePattern":"the release pointer is not an object: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/h1b-sponsor/install-h1b-index.mjs","lineNumber":117,"sourceCode":" * Both fields are validated before use. They come from the network, and one of\n * them is about to become part of a URL and the other the sole thing standing\n * between a substituted download and a lookup that trusts it.\n */\nasync function fetchPointer(fetchImpl, url) {\n  const out = await fetchImpl(url, { timeoutMs: POINTER_TIMEOUT_MS }, async res => {\n    if (res.status !== 200) return { status: res.status };\n    const read = await readBoundedText(res, MAX_POINTER_BYTES);\n    return read.oversized ? { oversized: true } : { text: read.text };\n  });\n  if (out.status) throw new Error(`could not read the release pointer (HTTP ${out.status}): ${url}`);\n  if (out.oversized) throw new Error(`the release pointer is implausibly large: ${url}`);\n\n  let doc;\n  try {\n    doc = JSON.parse(String(out.text || ''));\n  } catch {\n    throw new Error(`the release pointer is not JSON: ${url}`);\n  }\n  if (!doc || typeof doc !== 'object') throw new Error(`the release pointer is not an object: ${url}`);\n\n  const filename = String(doc.filename || '');\n  if (!FILENAME_RE.test(filename)) {\n    throw new Error(`the release pointer names an unusable index filename (${JSON.stringify(doc.filename)}): ${url}`);\n  }\n  const sha256 = String(doc.sha256 || '').trim().toLowerCase();\n  if (!SHA256_RE.test(sha256)) {\n    throw new Error(`the release pointer does not carry a sha256 digest: ${url}`);\n  }\n  // Recorded, never acted on, so a missing or odd value costs a label rather\n  // than the install. Bounded because it lands in a file on disk.\n  const version = doc.version === undefined || doc.version === null\n    ? null\n    : String(doc.version).slice(0, 64);\n  return { filename, sha256, version };\n}\n","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/plugins/h1b-sponsor/install-h1b-index.mjs#L99-L135","documentation":"After successfully JSON-parsing the release pointer, the installer verifies the result is a non-null object (typeof 'object'). Values like arrays, numbers, strings, or literal null pass JSON.parse but fail this check, so the installer throws rather than dereferencing doc.filename blindly.","triggerScenarios":"Running install-h1b-index.mjs when the pointer URL serves valid JSON that is not an object: a bare JSON array ([...]), a quoted string, a number, or the JSON literal null — usually because the URL points at the wrong file or an API listing endpoint.","commonSituations":"Pointer URL accidentally pointing at a JSON array of releases from an API endpoint; a renamed/moved pointer file leaving an index-style JSON at the URL; hand-rolled mirror serving the wrong document.","solutions":["Check the URL's content with `curl -s <url>`; confirm it is a JSON object with `filename` and `sha256` fields.","Fix the pointer URL to point at the pointer document, not a releases list or other JSON.","If you run a mirror, update it to serve the expected pointer object shape `{\"filename\":..., \"sha256\":..., \"version\":...}`."],"exampleFix":"// before\ncurl -s \"$POINTER_URL\"   # [ {\"filename\": ...}, ... ]  (array)\n// after\ncurl -s \"$POINTER_URL\"   # {\"filename\":\"h1b-index.sqlite.zst\",\"sha256\":\"...\"}","handlingStrategy":"type-guard","validationCode":"const doc = JSON.parse(text);\nif (doc === null || typeof doc !== 'object' || Array.isArray(doc)) {\n  throw new TypeError('pointer must be a JSON object');\n}","typeGuard":"const isPointerObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) && typeof v.filename === 'string' && typeof v.sha256 === 'string';","tryCatchPattern":"try {\n  await installH1bIndex();\n} catch (e) {\n  if (e.message.includes('release pointer is not an object')) {\n    console.error(`Pointer at ${e.message.split(': ').pop()} is not a JSON object — verify the URL targets the pointer document.`);\n  } else throw e;\n}","preventionTips":["Confirm the URL serves the pointer object, not a releases array or version string.","If mirroring, replicate the exact pointer schema {filename, sha256, version}.","Add a startup assertion validating the pointer shape before use."],"tags":["json","validation","install"],"backgroundTag":"unexpected-response-shape","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}