Skip to content

compute: field validation errors are stripped of their detail #11458

@bjohnso5

Description

@bjohnso5

Client

Compute (but likely others, as well, due to code generation and sharing)

Dependencies

go.mod
module modname

go 1.23.2

require (
    ...
    cloud.google.com/go/compute v1.31.1
    github.com/googleapis/gax-go/v2 v2.14.1
    google.golang.org/api v0.215.0
	google.golang.org/grpc v1.69.2
	google.golang.org/protobuf v1.36.2
    ...
)

Expected behavior

API field validation details are preserved in Bad Request scenarios.

Actual behavior

With the recent update to the compute/apiv1/helpers.go (https://github.com/googleapis/google-cloud-go/blob/d448fbb8ff228b1081ebbc98ee13e2a49e2b373c/compute/apiv1/helpers.go), 400 Bad Request errors are being stripped of their details due to what I'm fairly certain is a bug trying to double-read the response body.

The response body is read here, and then again within the googleapi.CheckResponse call.

This returns error strings like "googleapi: Error 400:", where previously the failure would contain the invalid field details (e.g. Invalid value for field 'resource.instanceProperties.machineType').

Additional context

I believe this issue is caused by this PR.

Metadata

Metadata

Assignees

Labels

api: computeIssues related to the Compute Engine API.needs more infoThis issue needs more information from the customer to proceed.priority: p2Moderately-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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions