Skip to content

OpenTSDB PutDataPoints returns "invalid response type" when the datapoints argument has the wrong type #4323

Closed

Description

@NitinKumar004

Describe the bug

PutDataPoints checks the type of its datas argument but reports a failure using the response-type sentinel:

pkg/gofr/datasource/opentsdb/opentsdb.go:202-205

datapoints, ok := datas.([]DataPoint)
if !ok {
    return fmt.Errorf("%w: Must be []DataPoint", errInvalidResponseType)
}

So passing the wrong type for the input gives invalid response type: Must be []DataPoint, and errors.Is(err, errInvalidResponseType) matches even though the response was fine. The same file already uses errInvalidParam ("invalid parameter type") for the equivalent input check in QueryLatestDataPoints (:291-294).

Expected behavior

Return errInvalidParam for a wrong datas type:

return fmt.Errorf("%w: Must be []DataPoint", errInvalidParam)

Additional context

Found by @aryanmehrotra while reviewing #4274.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions