diff --git a/confmap/confmap.go b/confmap/confmap.go index d589d11aa67..c625b8b82fa 100644 --- a/confmap/confmap.go +++ b/confmap/confmap.go @@ -200,7 +200,6 @@ func decodeConfig(m *Conf, result any, errorUnused bool, skipTopLevelUnmarshaler // we unmarshal the embedded structs if present to merge with the result: unmarshalerEmbeddedStructsHookFunc(), zeroSliceHookFunc(), - negativeUintHookFunc(), ), } decoder, err := mapstructure.NewDecoder(dc) @@ -499,19 +498,6 @@ func zeroSliceHookFunc() mapstructure.DecodeHookFuncValue { } } -// This hook is used to solve the issue: https://github.com/open-telemetry/opentelemetry-collector/issues/9060 -// Decoding should fail when converting a negative integer to any type of unsigned integer. This prevents -// negative values being decoded as large uint values. -// TODO: This should be removed as a part of https://github.com/open-telemetry/opentelemetry-collector/issues/9532 -func negativeUintHookFunc() mapstructure.DecodeHookFuncValue { - return func(from reflect.Value, to reflect.Value) (interface{}, error) { - if from.CanInt() && from.Int() < 0 && to.CanUint() { - return nil, fmt.Errorf("cannot convert negative value %v to an unsigned integer", from.Int()) - } - return from.Interface(), nil - } -} - type moduleFactory[T any, S any] interface { Create(s S) T } diff --git a/confmap/confmap_test.go b/confmap/confmap_test.go index ac48d0359e6..32bf272d5d8 100644 --- a/confmap/confmap_test.go +++ b/confmap/confmap_test.go @@ -279,7 +279,7 @@ func TestUintUnmarshalerFailure(t *testing.T) { err := conf.Unmarshal(cfg) assert.Error(t, err) - assert.Contains(t, err.Error(), fmt.Sprintf("decoding failed due to the following error(s):\n\nerror decoding 'uint_test': cannot convert negative value %v to an unsigned integer", testValue)) + assert.Contains(t, err.Error(), fmt.Sprintf("decoding failed due to the following error(s):\n\ncannot parse 'uint_test', %d overflows uint", testValue)) } func TestMapKeyStringToMapKeyTextUnmarshalerHookFuncDuplicateID(t *testing.T) { diff --git a/internal/memorylimiter/config_test.go b/internal/memorylimiter/config_test.go index 032f4798988..2d5a08aebe3 100644 --- a/internal/memorylimiter/config_test.go +++ b/internal/memorylimiter/config_test.go @@ -99,6 +99,6 @@ func TestUnmarshalInvalidConfig(t *testing.T) { cfg := &Config{} err = cm.Unmarshal(&cfg) require.Error(t, err) - require.Contains(t, err.Error(), "error decoding 'limit_mib': cannot convert negative value -2000 to an unsigned integer") - require.Contains(t, err.Error(), "error decoding 'spike_limit_mib': cannot convert negative value -2300 to an unsigned integer") + require.Contains(t, err.Error(), "cannot parse 'limit_mib', -2000 overflows uint") + require.Contains(t, err.Error(), "cannot parse 'spike_limit_mib', -2300 overflows uint") }