Skip to content

fix(snowflake): add type assertion for SQL API response#334

Open
zhubzy wants to merge 3 commits intomainfrom
zhubzy/fix-typecheck-errors
Open

fix(snowflake): add type assertion for SQL API response#334
zhubzy wants to merge 3 commits intomainfrom
zhubzy/fix-typecheck-errors

Conversation

@zhubzy
Copy link
Copy Markdown
Contributor

@zhubzy zhubzy commented Mar 27, 2026

Summary

The Snowflake bubble's executeStatement method called response.json() which returns unknown in strict TypeScript, causing three TS18046 errors that were failing CI on main. This adds a type assertion matching the Snowflake SQL REST API response shape.

Related Issues

Fixes CI typecheck failures on main.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor
  • New Bubble Integration
  • Other (please describe):

Checklist

  • My code follows the code style of this project
  • I have added appropriate tests for my changes
  • I have run pnpm check and all tests pass
  • I have tested my changes locally
  • I have linked relevant issues

Screenshots (Required)

N/A — type-only fix, no UI changes.

Additional Context

The three errors were all in snowflake.ts at lines 205, 209, and 210:

error TS18046: 'result' is of type 'unknown'.

Summary by CodeRabbit

  • New Features

    • Added a new recommended model label "FLAGSHIP" (google/gemini-3-flash-preview) to model choices.
  • Refactor

    • Improved internal type annotations for handling external query responses to increase reliability and maintainability.

…6 errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 27, 2026 06:31
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

Added a type annotation for the Snowflake SQL REST API JSON response and added a new FLAGSHIP entry to the RECOMMENDED_MODELS mapping; both changes are additive and do not modify existing runtime behavior.

Changes

Cohort / File(s) Summary
Snowflake Response Typing
packages/bubble-core/src/bubbles/service-bubble/snowflake/snowflake.ts
Cast await response.json() to a typed shape where resultSetMetaData, data, and statementHandle are optional; existing fallback/default logic remains unchanged.
Recommended Models Update
packages/bubble-shared-schemas/src/ai-models.ts
Added FLAGSHIP: 'google/gemini-3-flash-preview' to the exported RECOMMENDED_MODELS mapping alongside existing entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 A rabbit hops through code so fine,

New types and models in a neat line.
Optional fields tucked in their place,
A flagship added with gentle grace.
I nibble bugs and leave a smiley trace. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: adding a type assertion for the Snowflake SQL API response to fix TypeScript errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 zhubzy/fix-typecheck-errors

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.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 27, 2026

Deploying bubblelab-documentation with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0e08e4e
Status: ✅  Deploy successful!
Preview URL: https://49dc9c84.bubblelab-documentation.pages.dev
Branch Preview URL: https://zhubzy-fix-typecheck-errors.bubblelab-documentation.pages.dev

View logs

…errors

# Conflicts:
#	packages/bubble-core/package.json
#	packages/bubble-runtime/package.json
#	packages/bubble-scope-manager/package.json
#	packages/bubble-shared-schemas/package.json
#	packages/create-bubblelab-app/package.json
#	packages/create-bubblelab-app/templates/basic/package.json
#	packages/create-bubblelab-app/templates/reddit-scraper/package.json
Copy link
Copy Markdown

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 addresses TypeScript strict-mode typecheck failures in the Snowflake service bubble by asserting the expected Snowflake SQL REST API JSON response shape, and also bumps package/template versions to 0.1.254.

Changes:

  • Add an explicit type assertion for response.json() in SnowflakeBubble.executeStatement to resolve TS18046 (unknown) errors.
  • Bump versions across several packages to 0.1.254.
  • Update create-bubblelab-app templates to depend on ^0.1.254 BubbleLab packages.

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/bubble-core/src/bubbles/service-bubble/snowflake/snowflake.ts Adds a JSON response type assertion for Snowflake SQL API responses to satisfy strict TS.
packages/bubble-core/package.json Bumps @bubblelab/bubble-core version to 0.1.254.
packages/bubble-runtime/package.json Bumps @bubblelab/bubble-runtime version to 0.1.254.
packages/bubble-shared-schemas/package.json Bumps @bubblelab/shared-schemas version to 0.1.254.
packages/bubble-scope-manager/package.json Bumps @bubblelab/ts-scope-manager version to 0.1.254.
packages/create-bubblelab-app/package.json Bumps create-bubblelab-app version to 0.1.254.
packages/create-bubblelab-app/templates/basic/package.json Updates template dependencies to ^0.1.254.
packages/create-bubblelab-app/templates/reddit-scraper/package.json Updates template dependencies to ^0.1.254.

Comment on lines +195 to +202
const result = (await response.json()) as {
resultSetMetaData?: {
numRows: number;
rowType: { name: string; type: string; nullable: boolean }[];
};
data?: (string | null)[][];
statementHandle?: string;
};
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

The Snowflake SQL API response shape is now duplicated inline as an anonymous type assertion. To reduce drift (especially since executeStatement already has an explicit return type), consider extracting a named type (e.g., SnowflakeStatementResponse) and reusing it here and in the function signature.

Copilot uses AI. Check for mistakes.
…_MODELS

The FLAGSHIP alias was removed when model tiers were reorganized into
provider-specific keys, but ai-agent.ts still references it for default
model config, causing undefined at runtime and 9 test failures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

🧹 Nitpick comments (1)
packages/bubble-shared-schemas/src/ai-models.ts (1)

44-69: Reminder: Run pnpm build:core after modifying shared schemas.

As per coding guidelines, shared schemas in /packages/bubble-shared-schemas require rebuilding since it is a separate package and types need to be regenerated. Ensure pnpm build:core is run after this modification.

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

In `@packages/bubble-shared-schemas/src/ai-models.ts` around lines 44 - 69, After
changing the shared schema constant RECOMMENDED_MODELS in
packages/bubble-shared-schemas/src/ai-models.ts, run the package build to
regenerate types and artifacts by executing pnpm build:core; this ensures the
updated RECOMMENDED_MODELS (and any exported types like AvailableModel) are
compiled and the dependent packages receive the updated schema artifacts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/bubble-shared-schemas/src/ai-models.ts`:
- Around line 44-69: After changing the shared schema constant
RECOMMENDED_MODELS in packages/bubble-shared-schemas/src/ai-models.ts, run the
package build to regenerate types and artifacts by executing pnpm build:core;
this ensures the updated RECOMMENDED_MODELS (and any exported types like
AvailableModel) are compiled and the dependent packages receive the updated
schema artifacts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ed267ac-9a20-42c4-b605-8e4a59cfc920

📥 Commits

Reviewing files that changed from the base of the PR and between 2146afc and 0e08e4e.

📒 Files selected for processing (1)
  • packages/bubble-shared-schemas/src/ai-models.ts

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