8000 listBuckets assumes XML type but type is not guaranteed · Issue #49 · xtyxtyx/minio-dart · GitHub
[go: up one dir, main page]

Skip to content

listBuckets assumes XML type but type is not guaranteed #49

Open

Description

@jmatze16

When parsing the XML results for providers like Backblaze it is not guaranteed that XML is going to be of type XmlElement. In my case there were XmlText objects. Because of this, it would throw a parsing error.

3.5.5 code in the listBuckets() function in minio.dart line 486.
return bucketsNode.children
.map((n) => Bucket.fromXml(n as XmlElement))
.toList();

Notice it assumes the type to be XmlElement as parses it as such but that is not guaranteed. Below is a change I suggest which avoids throwing errors by checking the type and not relying on type assumption:

List results = [];
for (xml.XmlNode node in bucketsNode.children) {
if (node is xml.XmlElement) {
results.add(Bucket.fromXml(node as XmlElement));
}
}

Im sure there is a more professional and elegant way to write the code than what I've written, but without type safety I need to fork your code with this change or things break with BackBlaze. Thanks!

Activity

  1. arrrrny commented on Oct 22, 2026

    @arrrrny

    Fixed in the fork. The children of <Buckets> are not guaranteed to be
    elements — a server that indents its XML puts whitespace text nodes between
    them — so the cast is gone:

    return bucketsNode.children
        .whereType<XmlElement>()
        .map(Bucket.fromXml)
        .toList();
  2. arrrrny commented on Oct 22, 2026

    @arrrrny

    This ships in zuraffa_minio — the maintained fork of this package, which upstream has not touched since August 2025.

    The fork keeps the API of the original package unchanged, so moving over is an import swap:

    // before
    import 'package:minio/minio.dart';
    // after
    import 'package:zuraffa_minio/minio.dart';

    Source, the changelog and the sweep of the open issues of this tracker: https://github.com/arrrrny/zuraffa_minio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      0