feat(agent): proxify ws executor call#1522
feat(agent): proxify ws executor call#1522arnaud-moncel wants to merge 4 commits intofeat/prd-214-setup-workflow-executor-packagefrom
Conversation
| const executorPath = context.path.replace( | ||
| WorkflowExecutorProxyRoute.AGENT_PREFIX, | ||
| WorkflowExecutorProxyRoute.EXECUTOR_PREFIX, | ||
| ); |
There was a problem hiding this comment.
🟡 Medium workflow/workflow-executor-proxy.ts:36
handleProxy uses context.path to construct the target URL, but path contains only the pathname without the query string. Requests with query parameters (e.g., ?foo=bar) lose those parameters when forwarded to the executor. Consider using context.url instead, which includes both the pathname and query string.
- const executorPath = context.path.replace(
+ const executorPath = context.url.replace(
WorkflowExecutorProxyRoute.AGENT_PREFIX,
WorkflowExecutorProxyRoute.EXECUTOR_PREFIX,
);🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file packages/agent/src/routes/workflow/workflow-executor-proxy.ts around lines 36-39:
`handleProxy` uses `context.path` to construct the target URL, but `path` contains only the pathname without the query string. Requests with query parameters (e.g., `?foo=bar`) lose those parameters when forwarded to the executor. Consider using `context.url` instead, which includes both the pathname and query string.
Evidence trail:
1. packages/agent/src/routes/workflow/workflow-executor-proxy.ts lines 36-40 (REVIEWED_COMMIT): Code uses `context.path.replace()` to construct `executorPath`, then `new URL(executorPath, this.executorUrl)` to create the target URL.
2. Koa documentation at https://koajs.com confirms: `request.path` - "Get request pathname" and `request.querystring` - "Get raw query string void of ?" - these are separate properties, confirming `path` does not include query parameters.
c938768 to
8891bf0
Compare
1 new issue
|
8891bf0 to
1f28b96
Compare
| const httpPort = Number(process.env.EXECUTOR_HTTP_PORT ?? '4001'); | ||
| const pollingIntervalMs = Number(process.env.EXECUTOR_POLLING_INTERVAL_MS ?? '5000'); |
There was a problem hiding this comment.
🟢 Low src/main.ts:40
Number(process.env.EXECUTOR_HTTP_PORT) and Number(process.env.EXECUTOR_POLLING_INTERVAL_MS) return NaN for invalid numeric strings (e.g., abc), silently propagating NaN to downstream code that expects a valid number. Unlike required env vars which throw on missing values, these misconfigurations fail silently and cause confusing downstream failures. Consider validating and throwing a clear error when the environment variable is set but not parsable as a number.
- const httpPort = Number(process.env.EXECUTOR_HTTP_PORT ?? '4001');
- const pollingIntervalMs = Number(process.env.EXECUTOR_POLLING_INTERVAL_MS ?? '5000');
+ const httpPort = parseIntEnv('EXECUTOR_HTTP_PORT', 4001);
+ const pollingIntervalMs = parseIntEnv('EXECUTOR_POLLING_INTERVAL_MS', 5000);Also found in 1 other location(s)
packages/agent/src/routes/workflow/workflow-executor-proxy.ts:19
Calling
.replace()onoptions.workflowExecutorUrlat line 19 will throw aTypeErrorif the value isnull. The typeAgentOptions.workflowExecutorUrlisstring | null, and the test factory in code object 1 defaults it tonull. IfWorkflowExecutorProxyRouteis instantiated whenworkflowExecutorUrlisnull, the constructor crashes with "Cannot read properties of null (reading 'replace')".
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file packages/workflow-executor/src/main.ts around lines 40-41:
`Number(process.env.EXECUTOR_HTTP_PORT)` and `Number(process.env.EXECUTOR_POLLING_INTERVAL_MS)` return `NaN` for invalid numeric strings (e.g., `abc`), silently propagating `NaN` to downstream code that expects a valid number. Unlike required env vars which throw on missing values, these misconfigurations fail silently and cause confusing downstream failures. Consider validating and throwing a clear error when the environment variable is set but not parsable as a number.
Evidence trail:
packages/workflow-executor/src/main.ts:40 - `const httpPort = Number(process.env.EXECUTOR_HTTP_PORT ?? '4001')` shows Number() parsing without validation
packages/workflow-executor/src/main.ts:41 - `const pollingIntervalMs = Number(process.env.EXECUTOR_POLLING_INTERVAL_MS ?? '5000')` same pattern
packages/workflow-executor/src/main.ts:70 - httpPort passed to Runner constructor
packages/workflow-executor/src/http/executor-http-server.ts:93 - `this.server.listen(this.options.port, resolve)` uses port directly
packages/workflow-executor/src/runner.ts:198 - `setTimeout(() => this.runPollCycle(), this.config.pollingIntervalMs)` uses interval directly
packages/workflow-executor/src/main.ts:24-30 - requireEnv() validates required vars but no equivalent for numeric validation
Also found in 1 other location(s):
- packages/agent/src/routes/workflow/workflow-executor-proxy.ts:19 -- Calling `.replace()` on `options.workflowExecutorUrl` at line 19 will throw a `TypeError` if the value is `null`. The type `AgentOptions.workflowExecutorUrl` is `string | null`, and the test factory in code object 1 defaults it to `null`. If `WorkflowExecutorProxyRoute` is instantiated when `workflowExecutorUrl` is `null`, the constructor crashes with "Cannot read properties of null (reading 'replace')".
1f28b96 to
d520398
Compare
Add a mock executor that simulates a complete "Customer Onboarding" workflow with all 7 step types (condition, read-record, update-record, trigger-action, load-related-record, mcp, guidance). No external dependencies needed — mock ports replace the orchestrator, agent, and AI. The front can connect via the standard HTTP endpoints. Also upgrade @langchain/core from 1.1.15 to 1.1.39 to fix the ERR_PACKAGE_PATH_NOT_EXPORTED error when running TS files with tsx. Run: npx tsx packages/workflow-executor/example/mock.ts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
d520398 to
25be9f0
Compare
Remove Dockerfile, .dockerignore, and main.ts entry point. These duplicate the example/ setup and are premature — Docker deployment will be added when we're ready to ship. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Coverage Impact ⬇️ Merging this pull request will decrease total coverage on Modified Files with Diff Coverage (3)
🤖 Increase coverage with AI coding...🚦 See full report on Qlty Cloud » 🛟 Help
|

Definition of Done
General
Security
Note
Add proxy routes for workflow executor under
/_internal/workflow-executions/*WorkflowExecutorProxyRoutethat registers three private routes (GET,POST,PATCH) under/_internal/workflow-executions/:runIdand proxies them to the workflow executor's/runs/*endpoints.workflowExecutorUrloption onAgentOptionscontrols whether the proxy is active; whennullor unset, no routes are registered.MockWorkflowPort,MockAgentPort,MockAiModelPort) and an expanded README to theworkflow-executorexample package.Macroscope summarized ba56cb7.