Need Help with Issues Encountered During SDK Migration to New Version?

Your approach to extracting the result from a RunActionResponse is solid and aligns well with Pipedream’s documented response structure: - ret: the main return value (if any) - exports: named exports, including $return_value and $summary - os: logs and errors (with errors as { k: 'error', err: { ... } }) What you’re doing well: - You check ret first, which is the primary return value. - You scan os for errors, which is important since errors may be logged there. - You check exports for $return_value and $summary, which covers most cases for exported data. - You provide a fallback error if nothing is found. Possible improvements: 1. Check for explicit errors first. If the action failed, it’s likely that os will contain an error, and ret/exports may be empty or misleading. Consider checking os for errors before returning ret or exports. 2. Return all error details. If you find an error in os, you might want to include the error name and stack in your returned error for better debugging. 3. Handle empty ret values. If ret is null or undefined, you might want to treat that as “no value returned” unless you expect null to be a valid result. 4. Consider returning more context. Sometimes, it’s helpful to return the full response (or at least the os logs) alongside the result or error for debugging. Suggested revision: ```
typescript function getResultFromActionResponse( response: RunActionResponse, ): TypedResult<unknown, Error> { // 1. Check for errors in logs first if (Array.isArray(response.os)) { for (const log of response.os) { const output = log as { ts?: number k?: ‘error’ err?: { name: string; message: string; stack: string } } if (output.k === ‘error’ && output.err) { const err = output.err; const error = new Error(err.message); error.name = err.name; // Optionally attach stack if needed // (error as any).stack = err.stack; return Result.error(error); } } } // 2. Check for a return value if (typeof response.ret !== “undefined” && response.ret !== null) { return Result.ok(response.ret); } // 3. Check for exports if (typeof response.exports === ‘object’ && response.exports !== null) { if (‘$return_value’ in response.exports) { return Result.ok(response.exports[‘$return_value’]); } if (‘$summary’ in response.exports) { return Result.ok(response.exports[‘$summary’]); } } // 4. Fallback error return Result.error(new Error(‘Tool did not return a value’)); }