Skip to content

A malformed enabled option fails open: only the literal false opts out #37

Closed

Description

@dmccoystephenson

What happens

The constructor treats only the literal false as the program's opt-out: options.enabled === false (trace-client.ts:255). Everything else from untyped code leaves reporting on, so enabled: 0, enabled: null, enabled: "" and enabled: "false" (a value read straight from a settings file or an environment variable) all send events.

The documented behavior is matched literally: the option is typed boolean, and "false yields a client that does nothing. Default true." The concern is the direction of the failure. A malformed opt-out fails open, in the one option that exists to stop reporting. The neighbouring key option went the other way in an earlier fix: a non-string key counts as missing, so the client sends nothing.

The README's own usage example is not affected, because it passes a real boolean (process.env.USAGE_REPORTING_ENABLED !== "false").

Why it was not fixed directly

Which values count as an opt-out, and the resulting disabledReason, are behavior that the three clients are meant to share. How trace-client-python and trace-client-java treat a non-boolean could not be checked, because their repositories could not be read from this run. A Java boolean cannot be malformed, while a Python truthiness check would already disagree with the code above.

Decision needed from the owner

  • Keep the current rule and say so in the TSDoc and README.
  • Or treat any value other than true and undefined as off, with disabledReason "config". This is the safer failure, and it would stop sending for any program that passes a truthy non-boolean today, so it needs a CHANGELOG entry and a check against the Python client.

This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Activity

  1. dmccoystephenson commented on Nov 20, 2026

    @dmccoystephenson
    MemberAuthor

    Resolved in PR #46 (0.5.0): when given, enabled is now read through TraceClient.allowsReporting() (trace-client.ts:287), so 0, null, "" and "false" turn reporting off with disabledReason "config".

    This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions