FluentStorage icon indicating copy to clipboard operation
FluentStorage copied to clipboard

null reference error when attempting recursive delete

Open GZTimeWalker opened this issue 6 months ago • 9 comments

[25-05-12 20:50:53.201 ERR] DefaultHealthCheckService: Health check Storage with status Unhealthy completed after 113.6429ms with message 'null'
System.ArgumentNullException: Value cannot be null. (Parameter 'source')
   at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)
   at FluentStorage.AWS.Blobs.AwsS3DirectoryBrowser.DeleteRecursiveAsync(String fullPath, CancellationToken cancellationToken)
   at FluentStorage.AWS.Blobs.AwsS3BlobStorage.DeleteAsync(String fullPath, AmazonS3Client client, CancellationToken cancellationToken)
   at FluentStorage.AWS.Blobs.AwsS3BlobStorage.DeleteAsync(IEnumerable`1 fullPaths, CancellationToken cancellationToken)
   at GZCTF.Services.HealthCheck.StorageHealthCheck.CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken) in /home/runner/work/GZCTF/GZCTF/src/GZCTF/Services/HealthCheck/StorageHealthCheck.cs:line 27

and I want to use newer OpenTelemetry.Instrumentation.AWS

Warning As Error: Detected package downgrade: AWSSDK.Core from 4.0.0 to 3.7.402.56. Reference the package directly from the project to select a different version.
GZCTF -> OpenTelemetry.Instrumentation.AWS 1.12.0 -> AWSSDK.Core (>= 4.0.0 && < 5.0.0)
GZCTF -> AWSSDK.Core (>= 3.7.402.56)

GZTimeWalker avatar May 12 '25 12:05 GZTimeWalker

This would be a breaking change. What happens if you add an explicit dependency on your project for v4 as the message states?

thompson-tomo avatar Jun 13 '25 12:06 thompson-tomo

This would be a breaking change. What happens if you add an explicit dependency on your project for v4 as the message states?

When explicitly specifying an upgrade to v4, it will pass the compilation but fail to run, resulting in a runtime error as shown above.

GZTimeWalker avatar Jun 13 '25 12:06 GZTimeWalker

Looking at the log & source code, I would suggest you splitting the issue in 2:

  • a defect for the error which can likely be solved by an if state in https://github.com/robinrodricks/FluentStorage/blob/develop/FluentStorage.AWS/Blobs/AwsS3DirectoryBrowser.cs to handle when response.S3Objects is null rather than an empty collection.
  • if you really want an enhancement to bump the min version of aws but I see little need especially if 1 gets fixed without it.

thompson-tomo avatar Jun 13 '25 13:06 thompson-tomo

Looking at the log & source code, I would suggest you splitting the issue in 2:

  • a defect for the error which can likely be solved by an if state in develop/FluentStorage.AWS/Blobs/AwsS3DirectoryBrowser.cs to handle when response.S3Objects is null rather than an empty collection.
  • if you really want an enhancement to bump the min version of aws but I see little need especially if 1 gets fixed without it.

Yeah I don't really want to bump up the minimum supported version, but maybe we can do some work around to make v4 compatible?

GZTimeWalker avatar Jun 13 '25 13:06 GZTimeWalker

I suspect #112 will solve your issue. Please checkout my fork & branch patch-1 so that you can test it locally.

Key thing is the new if check.

Please update the title to be "null reference error when attempting recursive delete"

thompson-tomo avatar Jun 13 '25 14:06 thompson-tomo

I suspect #112 will solve your issue. Please checkout my fork & branch pstch-1 so that you can test it locally.

Key thing is the new if check.

Please update the title to be "null reference error when attempting recursive delete"

Is this the only usage that leads to incompatibility?

GZTimeWalker avatar Jun 13 '25 14:06 GZTimeWalker

I can't see any other similar occurances

thompson-tomo avatar Jun 13 '25 14:06 thompson-tomo

@GZTimeWalker how did your testing go?

thompson-tomo avatar Jul 17 '25 13:07 thompson-tomo

@GZTimeWalker how did your testing go?

I haven't tested it yet, but I think it should be fine

GZTimeWalker avatar Jul 18 '25 14:07 GZTimeWalker