Skip to content

deck gateway sync triggers "UNIQUE violation..." error on certain changes for Plugins config #1848

@Waltuh2026

Description

@Waltuh2026

Hello! I've run into this issue where specific changes to a Plugins configuration throws the error decK sync stderr: Error: 1 errors occurred: while processing event: Create plugin {plugin name} for route {route name} failed: HTTP status 409 (message: "UNIQUE violation detected on '{instance_name=\"sandbox-test-plugin\"}'")

This seems like a bug but perhaps I'm missing an extra flag when running the sync, or something is wrong with the yaml?

Version and Syncing

Using Kong Deck 1.55.0-linux.
Kong Gateway version 3.10.0.3.
To sync I'm running deck gateway sync {my yaml file} --headers {my auth header}

Expected Result

Since I am changing the configuration for a plugin that's in a yaml with my route and service settings all using the same select_tags I expect it to succeed and update the items (specifically the Plugin).

Result Error

Changing some settings causes the deck gateway sync to fail with the following error:
decK sync stderr: Error: 1 errors occurred: while processing event: Create plugin {plugin name} for route {route name} failed: HTTP status 409 (message: "UNIQUE violation detected on '{instance_name=\"sandbox-test-plugin\"}'")

Reproduce This Error

I've provided the full .yaml I'm testing with at the bottom of this issue.
Seems like the error only occurs when changing certain settings. I've seen it happen when changing the route and service settings for a plugin.

  1. Run a Kong deck gateway sync for the yaml below to create it all.
  2. Then change anything other than the route or service setting for the plugin. For my example I'll change uri: /sandbox-example/endpoint/foobar to uri: /sandbox-example/endpoint
  3. Run deck gateway sync after the above change. This will succeed as expected, and we'll see the updated uri: setting for that plugin instance reflected in the sync output log, and on Kong Dashboard itself.
  4. Now, change the route that the plugin is applied to. route: devtools-sandbox-route-a gets changed to route: devtools-sandbox-route-b.
  5. Run deck gateway sync again. In this case I expect it to gracefully update the plugin in place, changing the route it's attached to but it throws the same error mentioned before in this issue.

Workarounds

One fix I've found is to just delete the existing Plugin instance on the Kong dashboard manually, then run the deck gateway sync which will then succeed.
The second is to rename the Plugins instance_name when changing the route or service on it. For example, if you followed the steps above, but then for step 4 also change the Plugins instance name to anything else it'll succeed. It deletes the old instance and then creates the new.

Yaml Example

_format_version: "3.0"
_workspace: kong_workspace_here
_info:
  select_tags:
    - devtools-sandbox
services:
    - name: devtools-sandbox-service
      host: devtools-sandbox.kong-dev.svc.cluster.local 
      enabled: true
      path: /
      port: 8080
      protocol: http
      read_timeout: 60000
      retries: 5
      write_timeout: 60000
      tags: &tags
        - sandbox
        - dev
        - dev-sandbox
      routes:
        - name: devtools-sandbox-route-a
          hosts: &hosts
            - kong.host.sandbox
          https_redirect_status_code: 426
          path_handling: v0
          paths:
            - /site/sandbox/route/a
          methods:
            - GET
          preserve_host: false
          protocols:
            - https
          regex_priority: 100
          request_buffering: true
          response_buffering: true
          strip_path: true
          tags: *tags
        - name: devtools-sandbox-route-b
          hosts: *hosts
          https_redirect_status_code: 426
          path_handling: v0
          paths:
            - /site/sandbox/route/b
          methods:
            - GET
          preserve_host: false
          protocols:
            - https
          regex_priority: 100
          request_buffering: true
          response_buffering: true
          strip_path: true
          tags: *tags
plugins:
  - name: request-transformer-advanced
    instance_name: sandbox-test-plugin-02
    route: devtools-sandbox-route-a
    config:
      dots_in_keys: false
      replace:
        uri: /sandbox-example/endpoint/foobar
    tags: *tags

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions