{"record":{"id":"d5b5b03a74b4975b","repo":"badges/shields","slug":"unparseable-yaml-response","errorCode":null,"errorMessage":"unparseable yaml response","messagePattern":"unparseable yaml response","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"error","filePath":"core/base-service/base-yaml.js","lineNumber":73,"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 = yaml.load(buffer.toString(), encoding)\n    } catch (err) {\n      logTrace(emojic.dart, 'Response YAML (unparseable)', buffer)\n      throw new InvalidResponse({\n        prettyMessage: 'unparseable yaml response',\n        underlyingError: err,\n      })\n    }\n    logTrace(emojic.dart, 'Response YAML (before validation)', parsed, {\n      deep: true,\n    })\n    return this.constructor._validate(parsed, schema)\n  }\n}\n\nexport default BaseYamlService\n","sourceCodeStart":55,"sourceCodeEnd":86,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/core/base-service/base-yaml.js#L55-L86","documentation":"_requestYaml parses the response body with `yaml.load(buffer.toString(), encoding)`; if the YAML parser throws, the error is logged as trace ('Response YAML (unparseable)') and rethrown as InvalidResponse 'unparseable yaml response' with the parser error as underlyingError. The body arrived but is not parseable YAML.","triggerScenarios":"The endpoint returned HTML/JSON/error pages instead of YAML, truncated downloads, tabs or invalid indentation in the YAML, duplicate keys or disallowed tags, or an encoding mismatch corrupting the text.","commonSituations":"Fetching .yml/.yaml via a URL that serves an HTML viewer (e.g. GitHub blob page instead of raw); malformed upstream config files; wrong branch/tag so a 404 page is parsed; Windows/encoding artifacts breaking indentation.","solutions":["Read the trace log 'Response YAML (unparseable)' and underlyingError to see the body and parser message","Use the raw-file URL for forge-hosted YAML (raw.githubusercontent.com etc.) instead of the HTML page","Validate the YAML file locally (e.g. with a linter) to find syntax issues like tabs or bad indentation","Pin a valid branch/tag/commit in the URL so the file always exists"],"exampleFix":"// before\nconst { yamlData } = await service._requestYaml({ url: 'https://gitlab.com/g/sh/-/blob/main/.gitlab-ci.yml' }) // HTML\n// after\nconst { yamlData } = await service._requestYaml({ url: 'https://gitlab.com/g/sh/-/raw/main/.gitlab-ci.yml' })","handlingStrategy":"try-catch","validationCode":"function assertLooksLikeYaml(body) {\n  const s = String(body).trim()\n  if (s.startsWith('<') || s.startsWith('{') || s.length === 0) throw new Error('response is not YAML (HTML/JSON/empty)')\n  if (/^\\s*[^#\\s][^\\n]*\\t/m.test(s)) throw new Error('YAML contains tab indentation')\n}\nassertLooksLikeYaml(buffer)","typeGuard":null,"tryCatchPattern":"try {\n  const { yamlData } = await service._requestYaml({ url })\n} catch (err) {\n  if (err.prettyMessage === 'unparseable yaml response') {\n    console.error('YAML parse failed:', err.underlyingError?.message)\n  } else throw err\n}","preventionTips":["Fetch raw YAML files, not HTML viewer pages","Run a local YAML linter on upstream files you depend on; avoid tabs in indentation","Pin valid branches/tags so 404 pages never reach the parser","Read trace log 'Response YAML (unparseable)' to see the offending body"],"tags":["yaml","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"}