Skip to content

fix(type-error): subblock migrations type error#4492

Merged
icecrasher321 merged 1 commit intostagingfrom
fix/type-error
May 7, 2026
Merged

fix(type-error): subblock migrations type error#4492
icecrasher321 merged 1 commit intostagingfrom
fix/type-error

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Build error fix

@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 7, 2026 8:14am

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 7, 2026

PR Summary

Low Risk
Low risk: small, localized change to migration typing/casting that should only affect how legacy subblock values are rewrapped during rename migrations.

Overview
Fixes migrateBlockSubblockIds to avoid a TypeScript type error by treating the migrated oldEntry as unknown and rebuilding the new subblock entry via explicit branches instead of a conditional expression.

When oldEntry is a record, the migration now normalizes missing value to null and explicitly casts type/value into BlockState['subBlocks'][string]; otherwise it wraps the raw value into a {id,type,value} object.

Reviewed by Cursor Bugbot for commit 911b217. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Greptile Summary

This PR fixes a TypeScript build error in subblock-migrations.ts by tightening the type of oldEntry from the inferred BlockState['subBlocks'][string] to unknown, enabling proper narrowing inside isPlainRecord. The ternary expression is replaced with an if/else block to satisfy the compiler without relying on a broad type assertion at the call site.

  • The isPlainRecord branch now explicitly extracts value via Object.hasOwn, falling back to null when the key is absent. Previously the spread would simply omit the property — the new behaviour ensures value is always present on the resulting object, which is a minor but intentional semantic improvement.
  • The else branch is unchanged in logic; oldEntry is cast to the value type since it is a non-record scalar.

Confidence Score: 5/5

Safe to merge — the change is a targeted type-safety fix with no functional regressions on the happy path.

The only observable behavioural change is that plain-record entries without a value key now produce value: null instead of omitting the property entirely, which is the more correct shape for BlockState subBlocks string. All other logic is preserved identically.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/workflows/migrations/subblock-migrations.ts Refactors migrateBlockSubblockIds to use if/else instead of a ternary, types oldEntry as unknown for safe narrowing, and explicitly sets value: null when a plain-record entry lacks the value key.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[migrateBlockSubblockIds] --> B{oldId in result?}
    B -- No --> C[skip]
    B -- Yes --> D{newId already in result?}
    D -- Yes --> E[delete oldId and skip]
    D -- No --> F[read oldEntry as unknown]
    F --> G{isPlainRecord?}
    G -- Yes --> H[resolve type from configuredType or oldEntry.type]
    H --> I[value = hasOwn value ? oldEntry.value : null]
    I --> J[assign spread oldEntry with id, type, value overrides]
    G -- No --> K[assign id, configuredType or DEFAULT, value cast from scalar]
    J --> L[delete result oldId]
    K --> L
Loading

Reviews (1): Last reviewed commit: "fix(type-error): subblock migrations typ..." | Re-trigger Greptile

@icecrasher321 icecrasher321 merged commit 49713f8 into staging May 7, 2026
10 checks passed
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.

1 participant