Skip to content

Empty responses return nil, nil #208

@ikonst

Description

@ikonst

The Send methods intentionally return nil, nil when content length is 0 and/or status code is 204. Recently we've experienced occasional panics in our code due to referencing fields on nil response. Those panics exhibited themselves only on a regional data center, leading us to suspect a localized Microsoft-side issue of truncating some responses. We have no evidence, unfortunately, as we haven't captured those responses in their raw form. The issue seems to have subsided by now.

In our code, we call "get" APIs and diligently check err. We have not considered the case of nil, nil since — let's say you're calling GetApplications() and get nil, nil - what does it mean? If it's an error then why err is unset? If it means no applications were found, then why is it not expressed as len(response.GetValue()) == 0?

My proposal would be to return a nil, err in cases when there's a response schema and there's no content in the response to satisfy it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Waits for author 🔁

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions