Skip to content

StatObjectAsync does not throw exception when object or bucket does not exist #953

@MihaiDaniel

Description

@MihaiDaniel

As per specifications found here:

And in this tutorial

When calling StatObjectAsync the method should throw an exception if the object is not found. But instead this seems to return an ObjectStat with default values instead.

I don't know if this is intended or not. I have not done anything special just installed it locally on windows 10, ran it and connected using a .NET 8 client. In the example below I just check the ETag if it's null or not, but I'm not sure if this is the best approach.

using IMinioClient minioClient = _minioClientFactory.CreateClient();
minioClient.WithSSL(false);

StatObjectArgs statObjectArgs = new StatObjectArgs()
	.WithBucket("notexists")
	.WithObject("randomStuff123456789");

ObjectStat objectStat = await minioClient.StatObjectAsync(statObjectArgs);
if (objectStat.ETag == null)	
{
	return NotFound(false);
}
return Ok(true);

Thanks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions