openfga / openfga/java-sdk

Bug: Metrics constructor mutates the Configuration object passed to it

Open
#292 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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 Configuration is shared across contexts, one path creating Metrics will silently add a TelemetryConfiguration that 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.