Layr-Labs / eigenda-proxy

EigenDA sidecar proxy server used for communication between rollup software and EigenDA.
MIT License
14 stars 20 forks source link

Bug: HTTP PUT requests panic with nil-pointer deref when no S3 configured #128

Closed samlaf closed 1 week ago

samlaf commented 2 weeks ago

See #125

Creating this issue to add more context, and also to propose another solution.

Proposed solution in #125 is to use reflection, however https://groups.google.com/g/golang-nuts/c/wnH302gBa4I/m/i_cPI8Gu9P8J states

This is a common source of confusion.  The basic answer is to never store something in an interface if you don't expect the methods to be called on it.  The language may allow it, but that violates the semantics of the interface.  To expound, a nil value should usually not be stored in an interface unless it is of a type that has explicitly handled that case in its pointer-valued methods and has no value-receiver methods.

which indicates that a better solution would be to set the interface itself to nil, as opposed to setting it to a nil pointer of the S3Store struct value, and then using reflection to check that the value is not nil.