Bug: Metrics constructor mutates the Configuration object passed to it
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 54
- Forks
- 26
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 9
Description
Summary
In src/main/java/dev/openfga/sdk/telemetry/Metrics.java:30-32, the Metrics constructor silently mutates the caller's Configuration:
if (this.configuration.getTelemetryConfiguration() == null) {
this.configuration.telemetryConfiguration(new TelemetryConfiguration());
}
Impact
- Side effect in constructor — Constructors should not modify their inputs.
- Shared Configuration objects are unsafe — If a
Configurationis shared across contexts, one path creatingMetricswill silently add aTelemetryConfigurationthat affects all other users of that object.
Proposed Fix
Instead of mutating the configuration, handle the null case defensively in the methods that read telemetry config. Alternatively, ensure a non-null default TelemetryConfiguration is set during Configuration construction so the null check is never needed.
Related
- PR #290 (telemetry instance sharing fix)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading src/main/java/dev/openfga/sdk/telemetry/Metrics.java:30-32 and inspect how Configuration and TelemetryConfiguration are constructed. Confirm the chosen fix prevents Metrics from mutating the caller's Configuration while safely handling a null telemetry configuration, and account for the telemetry instance sharing context from PR #290.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100