From 7067ffff119fff55bbfffef2fbaffbeb82d79b14 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 2 Aug 2026 15:38:40 +0200 Subject: [PATCH] daemon/pkg/opts: fix recursive NRI JSON decoding on go1.27 (JSON v2) Define the recursion-prevention type from NRIOpts instead of *NRIOpts. The named pointer type was handled correctly by the legacy JSON decoder, but Go 1.27's new JSON implementation resolves NRIOpts.UnmarshalJSON through it, causing infinite recursion and eventually a stack overflow. Using a distinct type with NRIOpts as its underlying type removes the method set while preserving the same fields and JSON representation. Signed-off-by: Sebastiaan van Stijn --- daemon/pkg/opts/nri_opts.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/daemon/pkg/opts/nri_opts.go b/daemon/pkg/opts/nri_opts.go index ba9c728543..3312043eff 100644 --- a/daemon/pkg/opts/nri_opts.go +++ b/daemon/pkg/opts/nri_opts.go @@ -19,11 +19,8 @@ type NRIOpts struct { func (c *NRIOpts) UnmarshalJSON(raw []byte) error { dec := json.NewDecoder(bytes.NewReader(raw)) dec.DisallowUnknownFields() - type nc *NRIOpts // prevent recursion - if err := dec.Decode(nc(c)); err != nil { - return err - } - return nil + type nriOpts NRIOpts // prevent recursion + return dec.Decode((*nriOpts)(c)) } // NamedNRIOpts is a NamedOption and flags.Value for NRI configuration parsing.