open-feature / open-feature/go-sdk
[BUG] telemetry: flag metadata values are copied into event attributes without type checking
- Dominant language
- Go
- Stars
- 249
- Forks
- 61
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 20
Description
## Observed behavior
`CreateEvaluationEvent` copies flag-metadata values straight into event attributes as `any`, with no type check:
https://github.com/open-feature/go-sdk/blob/6b0824c6c7b9b69e40f26aedcc4406ad4d3a5cec/openfeature/telemetry/telemetry.go#L66-L78
Go's `FlagMetadata` is `map[string]any`, so a provider returning `version: 3` puts an `int` into an attribute that [Appendix D](https://openfeature.dev/specification/appendix-d) types as `string`.
Go appears to be the only SDK where this is reachable:
- **JS** types flag metadata as `Record`.
- **Python** types it as `Mapping[str, bool | int | float | str]`.
- **Java**'s `ImmutableMetadata.getString` delegates to `getValue(key, String.class)`, documented to return `null` when the value is a different type — an explicit runtime type check.
## Expected Behavior
Assert `string` and omit the attribute (or coerce) on mismatch, following Java's precedent, so downstream OTel exporters receive correctly typed attributes.
Something like:
```go
if version, ok := details.FlagMetadata[flagMetaVersionKey].(string); ok {
attributes[VersionKey] = version
}
```
…applied to `contextId`, `flagSetId` and `version`.
## Steps to reproduce
```go
// provider returns FlagMetadata{"version": 3}
event := telemetry.CreateEvaluationEvent(hookContext, details)
fmt.Printf("%T\n", event.Attributes["feature_flag.version"]) // int, want string
```
Contributor guide
Research direction
Start in telemetry/telemetry.go at CreateEvaluationEvent, especially the metadata handling around lines 66–78. Check the contextId, flagSetId, and version values against the expected string type, then verify with the reproduction that mismatched metadata is omitted or handled consistently and valid values remain correctly typed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100