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/:id panics in internal/commands/api.(*apiOptions).fillPlaceholders at the project client call;
  • users/:user panics in the same function at the current-user client call.

After the fix:

go test ./internal/commands/api -run 'Test_fillPlaceholders|TestFillPlaceholdersReturnsAPIClientError' -count=1

passes, and git diff --check reports no errors.

Closes #8419 (closed)

Edited by Lee Seonghyeon · 이성현

Merge request reports

Loading
Loading