Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listBuckets assumes XML type but type is not guaranteed #49

Open
jmatze16 opened this issue Jul 31, 2022 · 0 comments
Open

listBuckets assumes XML type but type is not guaranteed #49

jmatze16 opened this issue Jul 31, 2022 · 0 comments

Comments

@jmatze16
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant