{"record":{"id":"c26afac8ba8318b3","repo":"badges/shields","slug":"unparseable-toml-response","errorCode":null,"errorMessage":"unparseable toml response","messagePattern":"unparseable toml response","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"error","filePath":"core/base-service/base-toml.js","lineNumber":74,"sourceCode":"  }) {\n    const logTrace = (...args) => trace.logTrace('fetch', ...args)\n    const mergedOptions = {\n      ...{ headers: this.constructor.headers },\n      ...options,\n    }\n    const { buffer } = await this._request({\n      url,\n      options: mergedOptions,\n      httpErrors,\n      systemErrors,\n      logErrors,\n    })\n    let parsed\n    try {\n      parsed = parse(buffer.toString())\n    } catch (err) {\n      logTrace(emojic.dart, 'Response TOML (unparseable)', buffer)\n      throw new InvalidResponse({\n        prettyMessage: 'unparseable toml response',\n        underlyingError: err,\n      })\n    }\n    logTrace(emojic.dart, 'Response TOML (before validation)', parsed, {\n      deep: true,\n    })\n    return this.constructor._validate(parsed, schema)\n  }\n}\n\nexport default BaseTomlService\n","sourceCodeStart":56,"sourceCodeEnd":87,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/core/base-service/base-toml.js#L56-L87","documentation":"_requestToml fetches a URL and parses the body with a TOML parser (`parse(buffer.toString())`); if parsing throws, the error is logged as trace and rethrown as InvalidResponse 'unparseable toml response' with the parser error attached as underlyingError. The server responded, but the body is not valid TOML for the schema this service expects.","triggerScenarios":"The upstream endpoint returned HTML (error/login page), JSON, or truncated TOML instead of a valid TOML document; a redirect landed on a human-readable page; Cargo.toml/pyproject-style files fetched from the wrong URL.","commonSituations":"Wrong raw-content URL (HTML view instead of raw file); 404/403 pages parsed as TOML; upstream project renamed/moved the config file; encoding issues corrupting the body.","solutions":["Check `underlyingError` (and trace logs 'Response TOML (unparseable)') to see the actual body and parser complaint","Ensure the URL returns the raw TOML file, not an HTML page (use the raw/serve endpoint for forge-hosted files)","Confirm the file exists and the branch/tag in the URL is correct","If the format legitimately changed, update the service's parsing/validation logic"],"exampleFix":"// before\nconst { tomlData } = await service._requestToml({ url: 'https://github.com/user/repo/blob/main/Cargo.toml' }) // HTML page\n// after\nconst { tomlData } = await service._requestToml({ url: 'https://raw.githubusercontent.com/user/repo/main/Cargo.toml' })","handlingStrategy":"try-catch","validationCode":"function assertLooksLikeToml(body) {\n  const s = String(body).trim()\n  if (s.startsWith('<') || s.startsWith('{') || s.length === 0) throw new Error('response is not TOML (HTML/JSON/empty)')\n}\n// before _requestToml, after checking status code\nassertLooksLikeToml(buffer)","typeGuard":null,"tryCatchPattern":"try {\n  const { tomlData } = await service._requestToml({ url })\n} catch (err) {\n  if (err.prettyMessage === 'unparseable toml response') {\n    console.error('TOML parse failed:', err.underlyingError?.message)\n  } else throw err\n}","preventionTips":["Use raw-file URLs, never HTML viewer URLs, for hosted TOML files","Check HTTP status/redirects so 404 pages aren't fed to the parser","Validate upstream TOML files locally when pinning a branch/tag","Read underlyingError — the TOML parser reports the exact line/syntax problem"],"tags":["toml","parsing","invalid-response"],"backgroundTag":"unparseable-response-body","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}