Skip to content

Add better feedback around the types for body argument #652

@natebosch

Description

@natebosch

The doc comment says that the body "can be a String, a List<int> or a Map<String, String>." however we allow any List or Map and then enforce the value types with a cast.

request.bodyBytes = body.cast<int>();
} else if (body is Map) {
request.bodyFields = body.cast<String, String>();

This is unnecessarily loose and may make the errors harder to diagnose. See error/stack in #644

I think we should consider making this more strict - require a List<String> instead of any List that happens to contain only String values, and same for Map. If we decide to do that we should only change it in the next major version.

We could also consider treating it as non-breaking to add an assert to help catch this kind of thing in tests. There are only a few existing cases that need to get fixed internally.

WDYT @lrhn @jakemac53 @kevmoo

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-breaking-releaseIssues that are worth doing but need to wait for a breaking version bump

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions