-
Notifications
You must be signed in to change notification settings - Fork 1.5k
bigquery: handleInsertErrors: equality check should be >=, not > #3519
Copy link
Copy link
Closed
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Client
BigQuery Go API
Environment
All
Go Environment
All
Code
https://github.com/googleapis/google-cloud-go/blob/bigquery/v1.14.0/bigquery/inserter.go#L226
The > check
if int(e.Index) > len(rows)should be >=
if int(e.Index) >= len(rows)Otherwise, the next lines can attempt to access an out of range index:
rie := RowInsertionError{
InsertID: rows[e.Index].InsertId,
RowIndex: int(e.Index),
}Expected behavior
No out of bounds errors
Actual behavior
panic: runtime error: index out of range [1] with length 1
goroutine 1432095 [running]:/vendor/cloud.google.com/go/bigquery.handleInsertErrors(0xc0002c8500, 0x3e8, 0x42a, 0xc000012708, 0x1, 0x1, 0x0, 0xc00f377ce8)
...vendor/cloud.google.com/go/bigquery/inserter.go:236 +0x56a/vendor/cloud.google.com/go/bigquery.(*Inserter).putMulti(0xc00029a7a0, 0xdbd580, 0xc04648e8d0, 0xc04649c200, 0x1, 0x1, 0x0, 0xdbd580)
.../vendor/cloud.google.com/go/bigquery/inserter.go:191 +0x3b1/vendor/cloud.google.com/go/bigquery.(*Inserter).Put(0xc00029a7a0, 0xdbd580, 0xc04648e870, 0xb6edc0, 0xc00023c980, 0x0, 0x0)
... // the rest of the stack trace is no longer in library code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.