feat(inbound-api): method-script exception detail on the inbound audit row, never on the HTTP body (D3)

This commit is contained in:
Joseph Doherty
2026-09-09 12:15:00 -04:00
parent a45857ddd6
commit 98c6809a66
6 changed files with 188 additions and 4 deletions
@@ -599,8 +599,12 @@ public class InboundScriptExecutor
catch (Exception ex)
{
_logger.LogError(ex, "Script execution failed for method {Method}", method.Name);
// Safe error message, no internal details
return new InboundScriptResult(false, null, "Internal script error", "SCRIPT_ERROR");
// Safe error message, no internal details — the caller only ever sees this.
// Flow Debugger step logs (design 2026-09-09 D3): the exception itself rides the
// additive ErrorDetail so the endpoint can put it on the inbound AUDIT row, where
// the Flow Debugger's inbound node reads it. It must never reach the HTTP body.
return new InboundScriptResult(
false, null, "Internal script error", "SCRIPT_ERROR", ErrorDetail: ex.ToString());
}
finally
{
@@ -743,8 +747,18 @@ public class InboundScriptContext
/// <c>SCRIPT_COMPILE_FAILED</c>, <c>SCRIPT_ERROR</c>). Null when the executor does not
/// classify the failure; the endpoint then falls back to <c>SCRIPT_ERROR</c>.
/// </param>
/// <param name="ErrorDetail">
/// Flow Debugger step logs (design 2026-09-09 D3): verbose, operator-only failure detail —
/// the method script's exception <c>ToString()</c>. <b>Audit-row only.</b> The endpoint stashes
/// it on <c>HttpContext.Items[AuditWriteMiddleware.ErrorDetailItemKey]</c> so it lands on the
/// inbound audit row (and therefore on the Flow Debugger's inbound node); it is NEVER written
/// to the HTTP response, which keeps carrying the sanitised <see cref="ErrorMessage"/>. Null
/// for failures whose message already says everything (timeouts, client aborts, site-scope
/// denials, compile failures).
/// </param>
public record InboundScriptResult(
bool Success,
string? ResultJson,
string? ErrorMessage,
string? ErrorCode = null);
string? ErrorCode = null,
string? ErrorDetail = null);