Files
capsule/internal/webhook/namespace
Cyril JouveandGitHub 4e9e529cfd fix(webhook): remove dead diff code block that panics on nil namespace metadata (#1976)
In userMetadataHandler.OnUpdate the per-request labels/annotations diff is computed twice. The inline block at the top clones oldNs metadata and diffs it against newNs, but its results are immediately shadowed by the `labels, annotations, err := userMetadataForValidation(...)` declaration in the `tnt.Spec.NamespaceOptions \!= nil` branch, which recomputes the same diff (via metadataForValidation) and is the only version actually passed to validateUserMetadata. The inline block is therefore dead code.

It is also a  panic: `maps.Clone(oldNs.GetAnnotations())` returns nil for a namespace with no annotations, and the following `annotations[key] = value` then panics with "assignment to entry in nil map" (same with labels).
This happens when using features like NamespaceOptions.AdditionalMetadataList on a namespace that had none.

The dead block and panic was introduced in a6927c5 (#1947).

Signed-off-by: Cyril Jouve <jv.cyril@gmail.com>
2026-06-22 11:29:23 +02:00
..