fix(ida): retain bounded stderr on upstream transport failures (#2449)
* fix(ida): retain bounded stderr on upstream transport failures * fix(ida): preserve stderr through operation and cleanup boundaries Address review findings at their producing boundaries and preserve directly affected consumers. Source inspection and git diff --check completed. Tests and automated checks were not run at the user’s explicit request. * fix(ida): preserve cancellation and single-owner stderr diagnostics --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -111,10 +111,18 @@ class IdaCleanupError extends ProviderAdapterError {
|
||||
) {
|
||||
super("ida", "close", {
|
||||
cause,
|
||||
capturedOutput:
|
||||
cause instanceof AnalysisError ? cause.capturedOutput : undefined,
|
||||
diagnostics: {
|
||||
...(cause instanceof AnalysisError ? cause.diagnostics : undefined),
|
||||
reason:
|
||||
"IDA cleanup could not be verified; the remaining connection or private workspace is retained for retry.",
|
||||
failure_reason: cause instanceof Error ? cause.message : String(cause),
|
||||
failure_reason:
|
||||
cause instanceof AnalysisError
|
||||
? (cause.diagnostics?.reason ?? cause.message)
|
||||
: cause instanceof Error
|
||||
? cause.message
|
||||
: String(cause),
|
||||
workspace: path,
|
||||
...(sessions === undefined
|
||||
? {}
|
||||
@@ -375,15 +383,47 @@ export class IdaSessionClient implements AnalysisClient {
|
||||
context: IdaOperationFailureContext,
|
||||
) {
|
||||
let failure: AnalysisError;
|
||||
if (
|
||||
if (wasCancelled(options))
|
||||
failure = new AnalysisCancelledError(operation, {
|
||||
cause,
|
||||
...(cause instanceof AnalysisError
|
||||
? {
|
||||
capturedOutput: cause.capturedOutput,
|
||||
diagnostics: cause.diagnostics,
|
||||
partialObservation: cause.partialObservation,
|
||||
cleanup:
|
||||
cause.cleanup ??
|
||||
(cause.cleanupIncomplete
|
||||
? {
|
||||
reason: cause.message,
|
||||
resources: cause.cleanupResources,
|
||||
}
|
||||
: undefined),
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
else if (
|
||||
cause instanceof ProviderAdapterError &&
|
||||
cause.operation === "transport"
|
||||
)
|
||||
failure = new ProviderAdapterError("ida", operation, {
|
||||
cause,
|
||||
capturedOutput: cause.capturedOutput,
|
||||
partialObservation: cause.partialObservation,
|
||||
cleanup: cause.cleanup,
|
||||
diagnostics: {
|
||||
...cause.diagnostics,
|
||||
recovery:
|
||||
"Check the configured upstream MCP registration and selected target; see docs/ida-provider.md.",
|
||||
},
|
||||
});
|
||||
else if (
|
||||
cause instanceof AnalysisError &&
|
||||
(cause.partialObservation !== undefined ||
|
||||
cause.cleanupIncomplete ||
|
||||
cause.capturedOutput !== undefined)
|
||||
)
|
||||
failure = cause;
|
||||
else if (wasCancelled(options))
|
||||
failure = new AnalysisCancelledError(operation);
|
||||
else if (cause instanceof AnalysisError) failure = cause;
|
||||
else if (cause instanceof z.ZodError)
|
||||
failure = new AnalysisOutputError(
|
||||
|
||||
Reference in New Issue
Block a user