Loading
fix(api): return client errors during placeholder expansion
Summary
glab api expands :id, :user, and :username placeholders by creating an API client. Both expansion paths discarded the client initialization error and dereferenced the returned client unconditionally.
When client initialization fails—for example because proxy, custom-header, OAuth, or host configuration is invalid—the command panics instead of returning the configuration error.
This change:
- propagates the API client initialization error from both placeholder paths;
- leaves the original endpoint value intact when expansion fails;
- adds table-driven regression coverage for the independent project and current-user paths.
Verification
Before the fix, the new cases fail independently with nil-pointer panics:
projects/:idpanics ininternal/commands/api.(*apiOptions).fillPlaceholdersat the project client call;users/:userpanics in the same function at the current-user client call.
After the fix:
go test ./internal/commands/api -run 'Test_fillPlaceholders|TestFillPlaceholdersReturnsAPIClientError' -count=1passes, and git diff --check reports no errors.
Closes #8419 (closed)
Edited by Lee Seonghyeon · 이성현