pulumi / pulumi-gcp

A Google Cloud Platform (GCP) Pulumi resource package, providing multi-language access to GCP
Apache License 2.0
185 stars 52 forks source link

HTTP 400 errors - Important Information Discarded #338

Open floyd-may opened 4 years ago

floyd-may commented 4 years ago

In attempting to work around https://github.com/terraform-providers/terraform-provider-google/issues/5898 (the solution to which appears to not be a comprehensive solution to my specific setup, but whatevs) I got a 400 error from the GCP api. I learned that the revision name of a Cloud Run revision needs to start with the name of the Cloud Run service. The only way I could learn that, however, was by cranking up TF_LOG to TRACE so that I could see the raw HTTP responses from the Terraform provider. There is very valuable information in the HTTP responses that don't get surfaced; instead, there's just a generic message.

Is it possible to bring the detailed error information from those 400 responses from GCP's REST API all the way through to the error messages that get displayed in the console? The current error messages are very much not actionable.

To repro: attempt to deploy a cloud run revision where Template:Metadata:Name doesn't end with the service's name. For instance:

return new cloudrun.Service("repro-example", new cloudrun.ServiceArgs
{
    Name = "repro-example",
    Traffics = new InputList<cloudrun.Inputs.ServiceTrafficArgs>
    {
        new cloudrun.Inputs.ServiceTrafficArgs
        {
            LatestRevision = true,
            Percent = 100
        }
    },
    Template = new cloudrun.Inputs.ServiceTemplateArgs
    {
        Metadata = new cloudrun.Inputs.ServiceTemplateMetadataArgs {
            Name = "goats-and-noodles", // notice it doesn't begin with "repro-example"
        },
        Spec = new cloudrun.Inputs.ServiceTemplateSpecArgs
        {
            Containers = new InputList<cloudrun.Inputs.ServiceTemplateSpecContainerArgs> {
                new cloudrun.Inputs.ServiceTemplateSpecContainerArgs {
                    Image = "us.gcr.io/something",
                }
            }
        },
    },
    Location = "us-central1"
});
floyd-may commented 4 years ago

Added a more robust repro example.

asadoughi commented 3 years ago

Another example when using gcloud vs Google Artifact Registry: ERROR: (gcloud.artifacts.repositories.create) Names may only contain lowercase letters, numbers, and hyphens, and must begin with a letter and end with a letter or number was only presented with 400 Invalid argument