Kong / deck

decK: Configuration management and drift detection for Kong
https://docs.konghq.com/deck/overview
Apache License 2.0
445 stars 130 forks source link

`deck validate` not catching a missing `#` at the end of a route #1418

Open ajrice6713 opened 1 month ago

ajrice6713 commented 1 month ago

We use deck validate to check our configurations before deploying instances of kong for testing in CI/CD.

I recently ran into an issue where a container would not start because the # was missing from the end of a regex route capture.

The service in our declarative file:

services:
  - name: myService
    host: my-alb-upstreamService.com
    protocol: https
    port: 443
    connect_timeout: 15000
    write_timeout: 30000    
    read_timeout: 30000
    retries: 3
    routes:
      - name: my_route
        priority: 150
        expression: lower(http.path) ~  r#"^/api/v[0-9]+/accounts/[0-9]+/someResource/[a-z0-9-]+/someSubResource(?:/.*)?$"
        preserve_host: true
        strip_path: false

The error output when we started the container:

Error: 2024/10/17 13:33:39 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:730: error parsing declarative config file /kong/declarative/kong.yml:
in 'services':
  - in entry 10 of 'services':
    in 'routes':
      - in entry 1 of 'routes':
        in '@entity':
          - in entry 1 of '@entity': Router Expression failed validation:  --> 1:1[18](https://github.com/Bandwidth/api-dev-config/actions/runs/11386053265/job/31677339752#step:9:19)
  |
1 | lower(http.path) ~ r#"^/api/v[0-9]+/accounts/[0-9]+/someResource/[a-z0-9-]+/someSubResource(?:/.*)?$"
  |                                                                                                                      ^---
  |
  = expected rawstr_char

Adding the missing # allowed my container to start - but I would expect this to have been caught when running deck validate