Skip to content

statObject method is crashing with Error: Null check operator used on a null value #108

@BirjuVachhani

Description

@BirjuVachhani

When calling statObject method with a valid, existent bucket and object key crashes with Null check operator used on a null value at following line:

return StatObjectResult(
      etag: etag,
      size: int.parse(resp.headers['content-length']!), // <------ Here
      metaData: extractMetadata(resp.headers),
      lastModified: parseRfc7231Time(resp.headers['last-modified']!),
      acl: retrieveAcls ? await getObjectACL(bucket, object) : null,
    );

Stacktrace:

Null check operator used on a null value
#0      Minio.statObject (package:minio/src/minio.dart:1136:53)
<asynchronous suspension>
#1      Future.timeout.<anonymous closure> (dart:async/future_impl.dart:1061:7)
<asynchronous suspension>

I debugged it and turns out, resp.headers is missing content-length field, hence the crash. I also noticed that size is a nullable param. So this can easily be solved by using int.tryParse instead of int.parse (Unless it is a real deep issue!).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions