Skip to content

fix: replace any types and @ts-ignore in SDK clients#583

Open
dev-punia-altimate wants to merge 1 commit intomainfrom
proposal/sdk-client-type-safety
Open

fix: replace any types and @ts-ignore in SDK clients#583
dev-punia-altimate wants to merge 1 commit intomainfrom
proposal/sdk-client-type-safety

Conversation

@dev-punia-altimate
Copy link
Copy Markdown

@dev-punia-altimate dev-punia-altimate commented Mar 30, 2026

What does this PR do?

Removes bare any types and @ts-ignore comments from the SDK client fetch wrappers in both v1 and v2 clients.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How did you verify your code works?

  • Verified TypeScript compiles without errors
  • The fix preserves identical runtime behavior (setting timeout=false on request objects)

Checklist

  • Code follows project style guidelines
  • Changes are limited to the fix scope

Issue for this PR

Identified by QA Autopilot code scan — both SDK clients use any types that bypass TypeScript type checking.

Category: type-safety
Severity: high
Files: packages/sdk/js/src/client.ts, packages/sdk/js/src/v2/client.ts

What I Found

Both SDK client files (client.ts and v2/client.ts) define a customFetch function with bare any types and a @ts-ignore comment to set req.timeout = false. This defeats TypeScript's type system at a critical boundary (the HTTP client).

Fix

  • Replaced const customFetch: any = (req: any) => with const customFetch = (req: Request): Promise<Response> =>
  • Replaced @ts-ignore + direct property set with a safe Record<string, unknown> assertion
  • Runtime behavior is identical

Auto-generated by QA Autopilot Proposal Monitor. Open for 30-day human review.

Summary by CodeRabbit

  • Refactor
    • Improved internal request handling in the JavaScript SDK client for better type safety and maintainability; no changes to public APIs or runtime behavior.

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@github-actions
Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • No issue referenced. Please add Closes #<number> linking to the relevant issue.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

The JS SDK client modules replace untyped request handlers that used TypeScript ignores with properly typed (req: Request) => Promise<Response> functions and set timeout via a type assertion on Request before delegating to global fetch.

Changes

Cohort / File(s) Summary
Client modules (typed fetch fallback)
packages/sdk/js/src/client.ts, packages/sdk/js/src/v2/client.ts
Replaced untyped (req: any) fetch fallbacks with typed (req: Request) => Promise<Response> wrappers. Assigns timeout using a type assertion (req as Request & { timeout: boolean }).timeout = false and then calls fetch(req). Removed @ts-ignore usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hopped in to tidy a type or two,

I cast the Request and set timeout true(ish),
No more ignores in TypeScript's view,
A cleaner fetch, a gentler wish,
— from a rabbit who loves neat code 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing any types and @ts-ignore from SDK clients.
Description check ✅ Passed The description covers the what and why, type of change, verification method, and checklist items, though it deviates from the template structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch proposal/sdk-client-type-safety

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Category: type-safety
Severity: high
Repo: altimate-code
@dev-punia-altimate dev-punia-altimate force-pushed the proposal/sdk-client-type-safety branch from b915112 to f962ec9 Compare March 31, 2026 05:28
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/sdk/js/src/client.ts`:
- Around line 10-12: The customFetch function contains dead code: the type
assertion and assignment (Request & { timeout: boolean }).timeout = false have
no effect on Node.js/undici fetch; remove that assertion and assignment from
customFetch and either leave customFetch as `const customFetch = (req: Request)
=> fetch(req)` or, if you need timeout control, implement it by accepting
RequestInit/AbortSignal (use AbortController.signal) or configuring an undici
dispatcher with headersTimeout/bodyTimeout; update any callers of customFetch
accordingly (refer to the customFetch function and its Request type assertion).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6163ee81-34a1-41b6-819f-dc31f349ce47

📥 Commits

Reviewing files that changed from the base of the PR and between b915112 and f962ec9.

📒 Files selected for processing (2)
  • packages/sdk/js/src/client.ts
  • packages/sdk/js/src/v2/client.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/sdk/js/src/v2/client.ts

Comment on lines +10 to 12
const customFetch = (req: Request) => {
;(req as Request & { timeout: boolean }).timeout = false
return fetch(req)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Node.js undici fetch request timeout property type

💡 Result:

In Undici's fetch implementation (used in Node.js), there is no direct "timeout" property on the fetch request options (RequestInit). Timeouts are configured via the optional "dispatcher" property, which accepts a Dispatcher instance (e.g., new Agent({ ... })) or similar. The relevant timeout properties on the dispatcher (e.g., Agent or Client constructor options, or DispatchOptions) are of type "number | null": - headersTimeout: number | null (time to receive headers, default 300000 ms) - bodyTimeout: number | null (time between body data, default 300000 ms) - connect.timeout: number (for connection timeout, nested under "connect" option) These are specified in Undici's Dispatcher.DispatchOptions and ClientOptions. Use 0 to disable. For fetch example: fetch(url, { dispatcher: new Agent({ headersTimeout: 10000, bodyTimeout: 10000 }) }) AbortSignal in RequestInit can also be used for overall request abortion, but it's not a numeric timeout property on the request itself.

Citations:


🏁 Script executed:

cat -n packages/sdk/js/src/client.ts | head -30

Repository: AltimateAI/altimate-code

Length of output: 1079


🏁 Script executed:

rg "timeout" packages/sdk/js/src/ -A 3 -B 3

Repository: AltimateAI/altimate-code

Length of output: 6926


🏁 Script executed:

rg "customFetch" packages/sdk/js/src/ -A 3 -B 3

Repository: AltimateAI/altimate-code

Length of output: 1548


🏁 Script executed:

# Check if there are any comments or documentation about this
rg "timeout.*false|false.*timeout" packages/sdk/js/ -A 2 -B 2

Repository: AltimateAI/altimate-code

Length of output: 1877


🏁 Script executed:

git log --oneline -p packages/sdk/js/src/client.ts | grep -A 10 -B 10 "timeout" | head -50

Repository: AltimateAI/altimate-code

Length of output: 713


🏁 Script executed:

# Check if there are any TODOs or comments in the file explaining this
grep -n "TODO\|FIXME\|NOTE\|HACK" packages/sdk/js/src/client.ts

Repository: AltimateAI/altimate-code

Length of output: 50


Remove dead code: timeout property has no effect on Node.js fetch behavior.

Setting timeout = false on the Request object has no effect in Node.js's undici implementation. Timeouts are configured via:

  • AbortSignal in RequestInit (e.g., fetch(req, { signal: controller.signal }))
  • dispatcher option with headersTimeout / bodyTimeout properties
  • Not via a timeout property on the Request object itself

The type assertion Request & { timeout: boolean } masks this non-functional property. This code should either be removed or replaced with proper timeout handling using AbortSignal or dispatcher configuration if timeout control is needed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/sdk/js/src/client.ts` around lines 10 - 12, The customFetch function
contains dead code: the type assertion and assignment (Request & { timeout:
boolean }).timeout = false have no effect on Node.js/undici fetch; remove that
assertion and assignment from customFetch and either leave customFetch as `const
customFetch = (req: Request) => fetch(req)` or, if you need timeout control,
implement it by accepting RequestInit/AbortSignal (use AbortController.signal)
or configuring an undici dispatcher with headersTimeout/bodyTimeout; update any
callers of customFetch accordingly (refer to the customFetch function and its
Request type assertion).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant