Kong / Kong/deck

Array field comparison behavior differs based on schema-default filling

Open
#2,188 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
503
Forks
137
Avg merge
3d 5h
Merged PRs (30d)
20

Description

## Context
The diff logic has a subtle behavior difference depending on whether schema-default filling is enabled.

## Behavior
When schema-default filling is **enabled**:
- Omitted array fields are filled with explicit `nil`
- This compares equal to `[]` that the gateway stores
- Diff reports no update needed

When schema-default filling is **disabled**:
- Omitted array fields remain absent from the config
- The distinction between absent and `[]` is preserved
- Diff correctly reports an update is needed

## Example
When **`kong.yaml`** is applied first and then **`kong-omitted.yaml`** is diffed, the behavior changes based on whether skip-filling defaults is enabled.

**`kong.yaml`**
```yaml
_format_version: "3.0"
plugins:
- name: zipkin
enabled: true
instance_name: zipkin-empty-array
protocols:
- http
- https
config:
http_endpoint: http://localhost:9411/api/v2/spans
static_tags: []
```

**`kong-omitted.yaml`**
```yaml
_format_version: "3.0"
plugins:
- name: zipkin
enabled: true
instance_name: zipkin-empty-array
protocols:
- http
- https
config:
http_endpoint: http://localhost:9411/api/v2/spans
```

_Originally posted in [#2184](https://github.com/Kong/deck/pull/2184#discussion_r3757710504)_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the diff with kong.yaml and kong-omitted.yaml, then trace the schema-default filling and skip-filling-defaults paths in the diff logic. Compare how omitted array fields and explicit nil are represented, and add or update coverage for both settings so the diff reports the intended update consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.