René's URL Explorer Experiment


Title: fix(copilot): clamp the legacy int4 size when materializing a chat upload by waleedlatif1 · Pull Request #6615 · simstudioai/sim · GitHub

Open Graph Title: fix(copilot): clamp the legacy int4 size when materializing a chat upload by waleedlatif1 · Pull Request #6615 · simstudioai/sim

X Title: fix(copilot): clamp the legacy int4 size when materializing a chat upload by waleedlatif1 · Pull Request #6615 · simstudioai/sim

Description: Summary materialize_file(operation: 'save') wrote the HEADed object size straight into workspace_files.size, which is still integer NOT NULL. A mothership chat attachment may be up to MAX_WORKSPACE_FILE_SIZE (5 GiB), so saving one issued SET size = 2^31-1> against int4. Postgres raises 22003; the retry filter matches only 23505, so it rethrows, the transaction rolls back, and the tool returns success: false with no way for the user to complete the save. No corruption — int4 overflows loudly, it never truncates — but the file could never be saved. Fix: clamp the legacy projection with the existing toLegacyWorkspaceFileSize() and dual-write the exact count to sizeBytes, which is what every other workspace_files size writer already does (server/metadata.ts x4, workspace-file-manager.ts:243/:1706, finalizers.ts:367). This call site was simply missed when the widening landed — the change converges it with the other six rather than inventing a third shape. The size source had to widen too. head?.size ?? row.size fell back to the clamped int4 column; now that the write also sets sizeBytes, that fallback would have overwritten an exact size_bytes with the clamp — and since the object is gone in that branch, nothing could recover it. row.sizeBytes ?? row.size is the same coalescing precedence the readers already use (workspace-file-manager.ts:227, finalizers.ts:399, metadata.ts:46). This branch is live whenever hasCloudStorage() is false, since the early return at the HEAD miss is cloud-only. Storage accounting keeps using the exact verifiedSize, so quota checks and usage increments are unaffected — only the legacy int4 projection is clamped. Severity — not release-blocking size_bytes is introduced by migration 0289 in this same release, and the legacy size column is integer NOT NULL, so an oversized row was never physically creatable. No backfill is needed and no existing row is affected — the original premise that legacy rows need one is inverted. The oversized path is not reachable today given the upload limits elsewhere in the stack, so this is correctness hardening landing before the column ships, not a fix for an active failure. It is a small change (13 source lines) that removes an unrecoverable failure mode at the point the ceiling would otherwise be hit. Follow-ups (deliberately out of scope) workspace-file-manager.ts:963 (trackChatUpload, insert branch) writes a caller-supplied size with no clamp and no sizeBytes. It is the next instance of this bug and sits upstream of the row this PR repairs. Converting loose external input from a DB error into a JS throw (the helper validates and throws on non-safe-integer/negative input) is a behavior change that deserves its own review rather than riding along here. A shared workspaceFileSizeColumns(bytes) helper returning { size, sizeBytes }, plus a lint guard so the dual-write cannot be half-applied. The two columns must always agree and are currently kept in sync by convention across independent call sites. That belongs with the contract phase — size cannot safely be dropped while unconverged writers exist. ee/workspace-forking/lib/copy/copy-files.ts:266/:312 copies meta.size (already int4-valid, so no overflow risk) but drops sizeBytes, so a forked large file lands with size_bytes = NULL and bills the clamped value. Read-side fix is coalesce(sizeBytes, size) at the select. Rollback note: once rows above 2 GiB exist, rolling back to a build without the coalescing readers makes them read as 2 GiB and corrupts storage counters. Type of Change Bug fix Testing bunx vitest run lib/copilot/tools/handlers/materialize-file.test.ts — 26 passed. Both new tests were proven red against the unfixed source: the clamp test fails with expected 3221225472 to be 2147483647, the fallback test with expected undefined to be 3221225472. bun run type-check clean; biome clean on both changed files. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Open Graph Description: Summary materialize_file(operation: 'save') wrote the HEADed object size straight into workspace_files.size, which is still integer NOT NULL. A mothership chat attachment may be up to MAX_...

X Description: Summary materialize_file(operation: 'save') wrote the HEADed object size straight into workspace_files.size, which is still integer NOT NULL. A mothership chat attachment may be up...

Opengraph URL: https://github.com/simstudioai/sim/pull/6615

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:585b17e6-6623-3b53-846f-9ce6ec780789
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD1DE:25245F:B5F42B:F9BB98:6AFB5368
html-safe-nonce1df393498e1340c725533d5e6f1c5f805e30aba0a09aba8d20954e3f7c8ba4ad
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMURFOjI1MjQ1RjpCNUY0MkI6RjlCQjk4OjZBRkI1MzY4IiwidmlzaXRvcl9pZCI6IjQ3Mjk0ODk5ODUyMzk3MzMwOTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac06518343c046e7e379e2636a288172be4fe08291e9a03233979eefe5139bd58d
hovercard-subject-tagpull_request:4260597058
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6615/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary materialize_file(operation: 'save') wrote the HEADed object size straight into workspace_files.size, which is still integer NOT NULL. A mothership chat attachment may be up to MAX_...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecbf66c024bb6d10e6955baa7413c54cf13a201bb
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/6615/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6615%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6615%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/6615/files
Reloadhttps://github.com/simstudioai/sim/pull/6615/files
Reloadhttps://github.com/simstudioai/sim/pull/6615/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/w27-file-size-int4-clamphttps://github.com/simstudioai/sim/tree/fix/w27-file-size-int4-clamp
Conversation 3 https://github.com/simstudioai/sim/pull/6615
Commits 1 https://github.com/simstudioai/sim/pull/6615/commits
Checks 30 https://github.com/simstudioai/sim/pull/6615/checks
Files changed https://github.com/simstudioai/sim/pull/6615/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6615/files
fix(copilot): clamp the legacy int4 size when materializing a chat upload https://github.com/simstudioai/sim/pull/6615/files#top
Show all changes 1 commit https://github.com/simstudioai/sim/pull/6615/files
5ecc178 fix(copilot): clamp the legacy int4 size when materializing a chat up… waleedlatif1 Aug 12, 2026 https://github.com/simstudioai/sim/pull/6615/commits/5ecc178ee9698cee57619105ec32e41cd5f5322a
Clear filters https://github.com/simstudioai/sim/pull/6615/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6615/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6615/files
materialize-file.test.ts https://github.com/simstudioai/sim/pull/6615/files#diff-1915d875019defbc450644f9309dce28f31a7d0f45740732814ceb51b46df5de
materialize-file.ts https://github.com/simstudioai/sim/pull/6615/files#diff-c1bd6ed8e2b10944a63adf2f291cb3c82fe8ab41259efb1631b366211b41e84a
apps/sim/lib/copilot/tools/handlers/materialize-file.test.tshttps://github.com/simstudioai/sim/pull/6615/files#diff-1915d875019defbc450644f9309dce28f31a7d0f45740732814ceb51b46df5de
View file https://github.com/simstudioai/sim/blob/5ecc178ee9698cee57619105ec32e41cd5f5322a/apps/sim/lib/copilot/tools/handlers/materialize-file.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6615/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6615/files#diff-1915d875019defbc450644f9309dce28f31a7d0f45740732814ceb51b46df5de
https://github.com/simstudioai/sim/pull/6615/files#diff-1915d875019defbc450644f9309dce28f31a7d0f45740732814ceb51b46df5de
https://github.com/simstudioai/sim/pull/6615/files#diff-1915d875019defbc450644f9309dce28f31a7d0f45740732814ceb51b46df5de
https://github.com/simstudioai/sim/pull/6615/files#diff-1915d875019defbc450644f9309dce28f31a7d0f45740732814ceb51b46df5de
apps/sim/lib/copilot/tools/handlers/materialize-file.tshttps://github.com/simstudioai/sim/pull/6615/files#diff-c1bd6ed8e2b10944a63adf2f291cb3c82fe8ab41259efb1631b366211b41e84a
View file https://github.com/simstudioai/sim/blob/5ecc178ee9698cee57619105ec32e41cd5f5322a/apps/sim/lib/copilot/tools/handlers/materialize-file.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6615/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6615/files#diff-c1bd6ed8e2b10944a63adf2f291cb3c82fe8ab41259efb1631b366211b41e84a
https://github.com/simstudioai/sim/pull/6615/files#diff-c1bd6ed8e2b10944a63adf2f291cb3c82fe8ab41259efb1631b366211b41e84a
https://github.com/simstudioai/sim/pull/6615/files#diff-c1bd6ed8e2b10944a63adf2f291cb3c82fe8ab41259efb1631b366211b41e84a
https://github.com/simstudioai/sim/pull/6615/files#diff-c1bd6ed8e2b10944a63adf2f291cb3c82fe8ab41259efb1631b366211b41e84a
https://github.com/simstudioai/sim/pull/6615/files#diff-c1bd6ed8e2b10944a63adf2f291cb3c82fe8ab41259efb1631b366211b41e84a
https://github.com/simstudioai/sim/pull/6615/files#diff-c1bd6ed8e2b10944a63adf2f291cb3c82fe8ab41259efb1631b366211b41e84a
Please reload this pagehttps://github.com/simstudioai/sim/pull/6615/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.