bcgov / api-services-portal

API Services Portal provides a multi-tenant frontend integrating API Gateway and Authorization services from Kong CE and Keycloak.
https://api.gov.bc.ca
Apache License 2.0
22 stars 7 forks source link

Environment failing to validate with "Unexpected error validating environment" #639

Closed ikethecoder closed 1 year ago

ikethecoder commented 1 year ago

API Services Portal Issue

User Story

As a API Provider,
I want to activate an environment
so that it appears on the API Directory.

Test Case

ENV

TESTCASE

EXPECTED

ACTUAL

ERROR

error: [wf.ValidateActiveEnv] Validation threw an exception TypeError: Cannot read properties of undefined (reading 'startsWith')
at /app/dist/services/workflow/validate-active-environment.js:121:153
at /app/dist/services/workflow/validate-active-environment.js:173:17
at Array.filter (<anonymous>)
at /app/dist/services/workflow/validate-active-environment.js:172:64
at Array.filter (<anonymous>)
at /app/dist/services/workflow/validate-active-environment.js:172:32
at Array.filter (<anonymous>)
at /app/dist/services/workflow/validate-active-environment.js:125:44
at Generator.next (<anonymous>)
at fulfilled (/app/dist/services/workflow/validate-active-environment.js:5:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
error: [general] GraphQL Error: You attempted to perform an invalid mutation

Notes

The plugin configuration for Gateway Routes are not getting parsed in the same way as the Gateway Service plugins, which results in an unexpected parsing check related to validation of the "well_known_template".

ikethecoder commented 1 year ago

Example minimal gateway config:

services:
- name: a-service-for-anontest
  host: httpbin.org
  tags: [ ns.anontest ]
  port: 443
  protocol: https
  retries: 0
  routes:
  - name: a-service-for-anontest-route
    tags: [ ns.anontest ]
    hosts:
    - a-service-for-anontest.api.gov.bc.ca
    paths:
    - /
    methods:
    - GET
    strip_path: false
    https_redirect_status_code: 426
    path_handling: v0
    request_buffering: true
    response_buffering: true
    plugins:
    - name: jwt-keycloak
      tags: [ ns.anontest ]
      config:
        allowed_iss: [ "https://auth.service" ]
        well_known_template: "https://auth.service/.well-known/configuration"