Skip to content

fix: replace type assertions with proper HttpError property#34

Merged
angelo-hub merged 2 commits into
feat/jira_view_relatedfrom
copilot/sub-pr-33
Dec 21, 2025
Merged

fix: replace type assertions with proper HttpError property#34
angelo-hub merged 2 commits into
feat/jira_view_relatedfrom
copilot/sub-pr-33

Conversation

Copilot AI commented Dec 21, 2025

Copy link
Copy Markdown
Contributor

Addresses type safety violations in RetryableHttpClient where retryAfterHeader was attached to HttpError instances via type assertions (error as any).

Changes

  • HttpError class: Added optional retryAfterHeader?: string | null parameter to constructor
  • Error creation (line 384-393): Pass header value in constructor instead of post-hoc assignment
  • Error consumption (line 324): Access typed property instead of using type assertion

Before/After

// Before: Type assertion bypass
const error = new HttpError(message, status, statusText, body, retryable);
if (response.status === 429) {
  (error as any).retryAfterHeader = response.headers.get("Retry-After");
}

// Later access also unsafe
const retryAfter = parseRetryAfter((error as any).retryAfterHeader || null);

// After: Type-safe throughout
const error = new HttpError(
  message, 
  status, 
  statusText, 
  body, 
  retryable,
  response.status === 429 ? response.headers.get("Retry-After") : undefined
);

// Later access is type-safe
const retryAfter = parseRetryAfter(error.retryAfterHeader ?? null);

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Added retryAfterHeader as optional property to HttpError class instead of using type assertions
- Updated line 324 to use error.retryAfterHeader instead of (error as any).retryAfterHeader
- Updated error instantiation to pass retryAfterHeader in constructor instead of attaching it afterwards
- Addresses type safety issues raised in PR review comments

Co-authored-by: angelo-hub <12058178+angelo-hub@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Jira view for related tickets feature fix: replace type assertions with proper HttpError property Dec 21, 2025
Copilot AI requested a review from angelo-hub December 21, 2025 18:28

@angelo-hub angelo-hub left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@angelo-hub
angelo-hub marked this pull request as ready for review December 21, 2025 18:38
@angelo-hub
angelo-hub merged commit 7453bc3 into feat/jira_view_related Dec 21, 2025
@angelo-hub
angelo-hub deleted the copilot/sub-pr-33 branch December 21, 2025 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants