ea81aa2eec
When _build_api_kwargs() throws an exception, the except handler in the retry loop referenced api_kwargs before it was assigned. This caused an UnboundLocalError that masked the real error, making debugging impossible for the user. Two _dump_api_request_debug() calls in the except block (non-retryable client error path and max-retries-exhausted path) both accessed api_kwargs without checking if it was assigned. Fix: initialize api_kwargs = None before the retry loop and guard both dump calls. Now the real error surfaces instead of the masking UnboundLocalError. Reported by Discord user gruman0.