Skip to content

Conversation

@ryoppippi
Copy link
Member

@ryoppippi ryoppippi commented Jan 1, 2026

Summary by cubic

Removed the unnecessary "as StackOneHeaders" cast when merging headers into actionHeaders in StackOneToolSet. This fixes a TypeScript type error and lets the branded header type be inferred from baseHeaders and extraHeaders.

Written for commit d7a2a90. Summary will update on new commits.

Copilot AI review requested due to automatic review settings January 1, 2026 11:34
@ryoppippi ryoppippi requested a review from a team as a code owner January 1, 2026 11:34
@ryoppippi ryoppippi merged commit ad101a3 into main Jan 1, 2026
15 checks passed
@ryoppippi ryoppippi deleted the remove-as branch January 1, 2026 11:34
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes a type assertion from the StackOneToolSet class that was forcing the result of defu(extraHeaders, baseHeaders) to be treated as the branded type StackOneHeaders. While removing unsafe type assertions is generally good practice, this specific change introduces a type compatibility issue.

Key Changes

  • Removed as StackOneHeaders type assertion from the merged headers result in the createRpcTool method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const extraHeaders = normalizeHeaders(additionalHeaders);
// defu merges extraHeaders into baseHeaders, both are already branded types
const actionHeaders = defu(extraHeaders, baseHeaders) as StackOneHeaders;
const actionHeaders = defu(extraHeaders, baseHeaders);
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

Removing the type assertion here will cause a type error. The defu function doesn't preserve TypeScript branded types, so the result will be inferred as Record<string, string> instead of StackOneHeaders. However, actionHeaders is passed to rpcAction() (lines 504, 512, 521) which expects StackOneHeaders | undefined according to the schema definition.

Instead of using a type assertion, consider validating the merged headers through the schema to properly maintain the branded type:

const actionHeaders = stackOneHeadersSchema.parse(defu(extraHeaders, baseHeaders));

This ensures type safety while avoiding unsafe type assertions.

Copilot uses AI. Check for mistakes.
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