Title: fix(workflows): pin a stored block retry policy when loading it by waleedlatif1 · Pull Request #6614 · simstudioai/sim · GitHub
Open Graph Title: fix(workflows): pin a stored block retry policy when loading it by waleedlatif1 · Pull Request #6614 · simstudioai/sim
X Title: fix(workflows): pin a stored block retry policy when loading it by waleedlatif1 · Pull Request #6614 · simstudioai/sim
Description: Summary A single out-of-range value in workflow_blocks.retry makes GET /api/workflows/[id] return 500 forever, bricking the workflow in the editor with no in-product repair. This makes the read tolerant while leaving the write strict. retry is bare jsonb typed as unknown, and load.ts asserted the stored blob was already a BlockRetryConfig: retry: (block.retry as BlockState['retry']) ?? undefined, It then handed that straight to the HTTP boundary, where workflowBlockStateSchema bounds maxTries to 2..5 and waitBetweenTriesMs to 0..5000. That schema is shared between the PUT /state body — where the bound is right — and the GET /api/workflows/[id] and /state responses, where it is fatal. The response .parse in the shared route builder throws a ZodError, which is not an OrchestrationError, so the error policy declines it and it falls through to a 500. Every UI write path reads the workflow first, so there is no way to fix the row from inside the product. The fix constructs a real BlockRetryConfig from the blob using the feature's own normalizeBlockRetryTries / normalizeBlockRetryWaitMs, filling defaults for missing fields and carrying enabled across unchanged. This lands ahead of the data. The retry column itself is brand new — migration 0288_workflow_blocks_retry landed two days ago in #6458 — so this is a pre-emptive guard arriving essentially alongside the column, not a repair of existing rows. That is the ideal time to add it: once a row goes out of range, the workflow is unopenable and there is no in-product way to fix it. Why the read is the right seam loadWorkflowFromNormalizedTablesRaw is the single read choke point for both apps — @sim/workflow-persistence for the Next app and the realtime server's full-state emit — so one edit covers every reader, and a normalized row self-heals on the next save. It matches clampParallelBatchSize a few lines below, which already pins a stored subflow value on the same path. The feature already declares clamp-on-read as its contract: the TSDoc on resolveBlockRetryConfig says bounds are clamped on read rather than rejected, and block-retry.test.ts asserts it. Execution has always honoured that. Only the read boundary disagreed. Six writers persist this column without bounding it: workflow:batch-add-blocks, workflow:replace-state, and workflow:update-block-retry on the realtime server — the first two take untyped block records v1/admin/workflows/import, v1/admin/workspaces/[id]/import, and superuser/import-workflow, which persist externally-authored workflow JSON server-side "Doesn't this silently change a value the user configured?" No — it makes the UI stop lying. The executor already clamps: resolveBlockRetryConfig pins the same bounds before a retry runs. Before this change, a block storing maxTries: 999 displayed 999 in the editor while execution ran 5. Now the editor shows 5, which is what actually happens. The displayed value and the executed value agree for the first time. enabled is carried across rather than resolved, so the numbers a builder configured survive switching retry off and back on. Alternatives rejected Validating on write. Leaves every existing bad row fatal forever, and would have to be repeated across three realtime ops plus roughly a dozen saveWorkflowToNormalizedTables callers, none of which share a validation seam. Bounding BlockRetrySchema in @sim/realtime-protocol. Its own TSDoc is correct that batch-add and replace-state bypass it, so this closes one writer and leaves the 500. Relaxing the response contract. Stops the 500 but leaves the editor rendering a number execution will never run. A contract test now pins the write bound so this shortcut fails loudly. Reusing resolveBlockRetryConfig. It returns null for a disabled policy, so it would erase the numbers a builder configured on every read. A dedicated test pins the opposite behavior. Type of Change Bug fix Testing Six cases in packages/workflow-persistence/src/load.test.ts, four of which are red without the load.ts change (verified by reverting the file and re-running): out-of-range enabled policy pinned to the bounds out-of-range disabled policy pinned without being discarded — the case that would let a resolveBlockRetryConfig-based patch ship green and be wrong missing fields filled with defaults non-boolean enabled resolved the way execution reads it in-range policy left untouched NULL reported as no policy (block runs once) Plus a contract test in apps/sim/lib/api/contracts/workflows.test.ts that the write bound still rejects out-of-range input. bun run type-check clean in apps/sim and packages/workflow-persistence; bun run check:api-validation passes; biome clean. 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 A single out-of-range value in workflow_blocks.retry makes GET /api/workflows/[id] return 500 forever, bricking the workflow in the editor with no in-product repair. This makes the read tol...
X Description: Summary A single out-of-range value in workflow_blocks.retry makes GET /api/workflows/[id] return 500 forever, bricking the workflow in the editor with no in-product repair. This makes the read tol...
Opengraph URL: https://github.com/simstudioai/sim/pull/6614
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,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-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:aad6540f-660a-3d7d-f91f-55cb4dd45b02 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9066:3ED756:28D605:38FF11:6AFB5309 |
| html-safe-nonce | a8dcaaecaddde5573f720ada73ee58cff578ebd63343514c0c0b0129a13f0317 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDY2OjNFRDc1NjoyOEQ2MDU6MzhGRjExOjZBRkI1MzA5IiwidmlzaXRvcl9pZCI6IjQzNzU0NTE5NDQwODUwNTAxMjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cac02ef74da74a58b2eabcc3aa9ae64b1e2828a371b1c161899640f1771daa6a |
| hovercard-subject-tag | pull_request:4260590252 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6614/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary A single out-of-range value in workflow_blocks.retry makes GET /api/workflows/[id] return 500 forever, bricking the workflow in the editor with no in-product repair. This makes the read tol... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width