2

My request flow is :

1.HTTP python client (a script) => 2. GCP API gateway => 3. validate request against firebase => 4. if request valid call cloud function v2 (cloud run)

  1. Python script is generating ID token from refresh token by using 'https://securetoken.googleapis.com/v1/token. And doing a request to API gateway using it.

  2. API gateway config is al follow.

swagger: "2.0"
info:
  title: Test
  description: API to read validated token details
  version: 1.0.0
paths:
  /test:
    get:
      x-google-backend:
        address: URL TO cloud function
      responses:
        "200":
          schema:
            $ref: '#/definitions/UserDetails'
          description: Successful response
      description: Returns details.
      operationId: testID
      summary: Get details from xyz
      security:
        - firebase: []
  .
  .
  .

definitions:
  UserDetails:
    title: Root Type for UserDetails
    description: User details object created from information in headers
    type: object
    properties:
      userId:
        type: string
      email:
        type: string      
securityDefinitions:
  firebase:
    flow: implicit
    authorizationUrl: ''
    scopes: {}
    type: oauth2
    x-google-issuer: "https://securetoken.google.com/*********"
    x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
    x-google-audiences: "******"
  1. This flow works fine but in between API gateway throws an error 500: Here are logs from gateway
{
  "insertId": "8310ad5-bf4-43b-966-d94485090890563961239@a1",
  "jsonPayload": {
    "http_status_code": 500,
    "location": "us-central1",
    "api_version": "1.0.0",
    "api_name": "removed",
    "producer_project_id": "removed",
    "service_agent": "ESPv2/2.35.0",
    "log_message": "removed",
    "response_code_detail": "via_upstream",
    "timestamp": 1664181080.6733284,
    "api_key_state": "NOT CHECKED",
    "api_method": "removed"
  },
  "httpRequest": {
    "requestMethod": "POST",
    "requestUrl": "/test",
    "requestSize": "5411",
    "status": 500,
    "responseSize": "599",
    "remoteIp": "600:1900:200:a3::16",
    "latency": "0.009s",
    "protocol": "http"
  },
  "resource": {
    "type": "api",
    "labels": {
      "method": "removed",
      "version": "1.0.0",
      "service": "removed",
      "project_id": "removed",
      "location": "us-central1"
    }
  },
  "timestamp": "2022-09-26T08:31:20.673328479Z",
  "severity": "ERROR",
  "logName": "removed"
}

Note : The client script is scheduled from different places parallely.

Anyone knows root cause ? issue is coming randomly, like sometime for 24 hours it wont come, suddenly it comes, and comes after few minutes again...

Sathi Aiswarya
  • 2,068
  • 2
  • 11
Djai
  • 188
  • 10
  • I've been having a very similar issue myself. It seems like there is a issue tracker here, but no real resolution... https://issuetracker.google.com/issues/117181234 – Leo Glowacki Oct 11 '22 at 18:41
  • Have a look at this [document](https://cloud.google.com/api-gateway/docs/troubleshoot#api_request_returns_an_http_401_or_500_error) – Sathi Aiswarya Nov 02 '22 at 06:11
  • @SathiAiswarya , I already tried solution suggested in this page but it still didn't work. I dont think if its related to service account as i have never changed settings. I also attached dedicated with required permission, still same issue. – Djai Nov 02 '22 at 07:52
  • The [issue tracker](https://issuetracker.google.com/issues/117181234) mentioned by Leo Glowacki is marked as Fixed and after cheking your issue i think it also relates to same issue tracker. As it closed I suggest to get your issue resolved I recommned to raise new [issue tracker](https://issuetracker.google.com/issues/) by referencing the fixed one or else you may rasie [support ticket with google](https://support.google.com/) – Sathi Aiswarya Nov 02 '22 at 12:24

0 Answers0