azure-sdk-for-js
azure-sdk-for-js copied to clipboard
Initialize state.result in failed LRO operations
The memory store update poller was not initializing state.result when operations failed, creating inconsistency with successful terminal states and potential issues for consumers expecting a defined result.
Changes
- Initialize
state.resultwith default value in failed state (empty operations array, zero usage) matching the pattern used for succeeded/superseded states
if (parsed.status === "failed") {
state.status = "failed";
if (!state.error) {
state.error = parsed.error
? new Error(parsed.error.message ?? "Memory update failed")
: new Error("Memory update failed");
}
// Initialize result with default value for consistency, even on failure
state.result = parsed.result ??
state.result ?? {
memory_operations: [],
usage: createDefaultUsage(),
};
return;
}
This ensures state.result is always defined in terminal states, preventing undefined access when processResult casts state.result as MemoryStoreUpdateResult.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.