FrendsFrends
All ideas

NullReferenceException in error handler of AmazonS3 ListObjects

Task full name: AmazonS3 ListObjects, Frends.AmazonS3.ListObjects.2.1.0 Task version: 2.1.0 Frends version: 6.1.3.3217 .NET platform: NET 8 Operating system: Windows I'm getting following error in Frends { "ClassName": "System.NullReferenceException", "Message": "Object reference not set to an instance of an object.", "Data": null, "InnerException": null, "HelpURL": null, "StackTraceString": " at Frends.AmazonS3.ListObjects.Helpers.ErrorHandler.Handle(Exception exception, Options options)\r\n at Frends.AmazonS3.ListObjects.AmazonS3.ListObjects(Connection connection, Input input, Options options, CancellationToken cancellationToken)\r\n at Frends.ExecutableProcess.XXX.XXX.ExecuteAsync(Object triggerDetails, Object environmentVariables, Object processVariables, Object process, CancellationToken cancellationToken, Func3 executeSubprocessAsync, Func3 executeSharedStateCommandAsync, Func3 executeDmnAsync, Func3 sendTcpMessageAsync, Func3 executeNativeAiAsync, LogLevel logLevel) in Frends.ExecutableProcess.XXX.cs:line 69", "RemoteStackTraceString": null, "RemoteStackIndex": 0, "ExceptionMethod": null, "HResult": -2147467261, "Source": "Frends.AmazonS3.ListObjects", "WatsonBuckets": null } I suspect it comes from error handler, lines: https://github.com/FrendsPlatform/Frends.AmazonS3/blob/c6f6432eff426db588ec8c5eaba14bdd8dffbf0c/Frends.AmazonS3.ListObjects/Frends.AmazonS3.ListObjects/Helpers/ErrorHandler.cs#L22 and https://github.com/FrendsPlatform/Frends.AmazonS3/blob/c6f6432eff426db588ec8c5eaba14bdd8dffbf0c/Frends.AmazonS3.ListObjects/Frends.AmazonS3.ListObjects/Helpers/ErrorHandler.cs#L26 What bot says about root cause: Issue: NullReferenceException when S3 ListObjects fails Why it happens When an exception occurs in ListObjects(...), the catch block calls ErrorHandler.Handle(ex, options). Inside ErrorHandler.Handle, the code assumes options is not null. In some failure paths (e.g. task input binding/validation or earlier failures), options is actually null, causing a new exception while handling the original one. Failing lines (root cause) // ErrorHandler.Handle(...) if (options.ThrowErrorOnFailure) // options can be null → NullReferenceException throw exception; var errorMessage = string.IsNullOrWhiteSpace(options.ErrorMessageOnFailure) ? exception.Message // also unsafe if options is null : $"{options.ErrorMessageOnFailure}: {exception.Message}"; Resulting behavior The original AWS/S3 error is masked A misleading System.NullReferenceException is thrown from ErrorHandler.Handle How to fix Make the error handler null-safe (and optionally default options` earlier): public static Result Handle(Exception exception, Options options) { if (options?.ThrowErrorOnFailure == true) throw exception; var errorMessage = string.IsNullOrWhiteSpace(options?.ErrorMessageOnFailure) ? exception.Message : $"{options.ErrorMessageOnFailure}: {exception.Message}"; var error = new Error( errorMessage, new { OriginalException = exception.GetType().Name, StackTrace = exception.StackTrace }); return new Result(error); } Optional defensive improvement // In ListObjects(...) options ??= new Options(); This prevents secondary failures and ensures the original exception is correctly reported.