---
id: w6/m9/t003
title: "Collapse GitHub upstream 5xx error body before forwarding to bex-api callers"
worker: worker6
status: done
estimate: 20m
depends_on: []
---

## Objective

Stop forwarding GitHub's raw 5xx response body to bex-api callers, per `w6/005`.

## Context

- `lego/backend/internal/github/client.go:123` — `APIError.Error()` interpolates the raw upstream body.
- 4xx `APIError`s are already flattened to `core.ErrBadRequest` by `mapGitHubErr`; 5xx pass through `core.WriteErr` unmodified.

## Steps

1. In the 5xx path, replace the verbatim body with a fixed message (e.g. `core.Err("github upstream error")`) or truncate `e.Body` before it reaches `core.WriteErr`.

## Files

- `lego/backend/internal/github/client.go`

## Acceptance criteria

- [ ] A simulated GitHub 5xx response no longer surfaces its raw body text to a bex-api caller.
- [ ] 4xx behavior is unchanged.

## Out of scope

- Changing 4xx error handling.
