router-for-me/CLIProxyAPI · error

failed to read Codex live request

Error message

failed to read Codex live request: %w

What it means

Error "failed to read Codex live request: %w" thrown in router-for-me/CLIProxyAPI.

Solutions

  1. Verify the request body is complete and within the size limit.
  2. Check the wrapped error for truncated or aborted request bodies.

When it happens

Trigger: Thrown at internal/client/codex/live/live.go:514 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/78d7220cb1518f6f. Report an issue: GitHub.

Appendix: source

Thrown at internal/client/codex/live/live.go:514

		}
	} else {
		selected, errSelect = h.authManager.SelectAuthByKind(ctx, "codex", "", auth.AuthKindOAuth, opts)
	}
	if errSelect != nil && selection != nil {
		selection.End("selection_failed")
	}
	return selection, selected, errSelect
}

var errBodyTooLarge = errors.New("Codex live request body too large")

func readBody(body io.Reader) ([]byte, error) {
	payload, errRead := readLimitedBody(body)
	if errRead != nil {
		if errors.Is(errRead, errBodyTooLarge) {
			return nil, errRead
		}
		return nil, fmt.Errorf("failed to read Codex live request: %w", errRead)
	}
	return payload, nil
}

func readLimitedBody(body io.Reader) ([]byte, error) {
	if body == nil {
		return nil, nil
	}
	payload, errRead := io.ReadAll(io.LimitReader(body, maxBodySize+1))
	if errRead != nil {
		return nil, errRead
	}
	if len(payload) > maxBodySize {
		return nil, errBodyTooLarge
	}
	return payload, nil
}

View on GitHub (pinned to 78f0c4079e)