fix(function): omit oversized display code instead of failing the execution

Merged
WA
1mo ago
+31-2

Summary

  • #8344 capped the Function execute contract's sourceCode at the 1 MiB source limit. sourceCode isn't the code that runs. It's the display copy used only to render errors, and the resolver inlines each referenced block output into it in full, while the executed code carries those values as __blockRef_N bindings. A Function block that references a large upstream output (e.g. data = <api.data> over ~1 MiB, which Python and shell never offload) therefore produced a request the route rejected, although its executed code was tiny. That same workflow runs on main
  • buildFunctionExecuteBody now omits sourceCode when it exceeds MAX_FUNCTION_CODE_LENGTH. Error rendering already falls back to the executed code when sourceCode is absent, which keeps line numbers correct; truncating would misplace them. The route keeps #8344's bound on both fields, and the cap on the executed code is unchanged

Type of Change

  • Bug fix

Testing

  • New execute.test.ts case: a body whose display code outgrows the cap passes the real functionExecuteBodySchema and carries no sourceCode, and display code within the cap is still sent. It fails on staging (safeParse(...).success === false)
  • Function tool, handler, route, and function-execution suites (371 tests), including #8344's own oversized-input rejections, pass. Type-check, lint, and check:audits pass

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)