snowplow / snowplow-golang-analytics-sdk

Golang Analytics SDK for working with Snowplow enriched events in cloud functions and other Go applications.
https://snowplowanalytics.com/
Apache License 2.0
5 stars 1 forks source link

Make `GetContextValue()` and `GetUnstructValue()` behaviour consistent when field does not exist #37

Open colmsnowplow opened 2 years ago

colmsnowplow commented 2 years ago

GetUnstructValue() returns an error when the path provided doesn't exist, whereasGetContextValue() returns nil with no error.

I believe these were simply two API design choices that were made independently, and there's good reason for these in isolation to behave this way - for contexts, there can be several of the same context - some of which may contain an optional field whereas some don't. In that case, we don't want to error if we find one but not the other.

We should reconsider whether or not this is the best design, since it's unintuitive - one would expect these to behave in something of a consistent manner.