Skip to content

Follow-up: expose Trace seam for config-loader diagnostics (dime T2) #245

Description

@ottobolyos

Origin

Dime Ultrareview cycle-1 on PR #241 (fix/device-validation-level-hardening), tracked finding T2 — surfaced by the code-review agent.

Finding

PR #241 replaces the four silent `catch { }` blocks in `AgentConfiguration.ReadJson` / `ReadJson(Type,…)` / `ReadYaml` / `ReadYaml(Type,…)` with:

  1. A rethrow of `ArgumentOutOfRangeException` wrapped as `ArgumentException` with the configuration path attached (bad-enum config surfaces the actionable setter message).
  2. A `System.Diagnostics.Trace.TraceError($"Config load failed: {configurationPath}: {ex.Message}")` call before the null-return preservation path.

The Trace call surfaces the diagnostic to any `TraceListener` a host has registered — but that's a global-registry side effect the tests can only observe by installing a listener during `[SetUp]`. A test-friendly `ILogger` / `Action<string, Exception>` seam would let unit tests assert the diagnostic surface without touching the global `Trace` machinery.

Rationale for defer

Adding a logging seam is API-surface-shaped work — it changes the `AgentConfiguration` public shape (or introduces a new `static Action<string, Exception>? OnConfigLoadFailure` static delegate seam). That's a decision the maintainer should weigh independently of the H2 swallow fix; it does not gate landing the swallow removal.

Suggested design (for the follow-up PR)

  • Add `public static Action<string, Exception>? OnConfigLoadFailure { get; set; }` on `AgentConfiguration`.
  • Invoke it inside the H2 catch fallback, alongside the existing `Trace.TraceError` call.
  • Add a unit test that sets the delegate, triggers a malformed-JSON load, and asserts the delegate was invoked with the expected path + exception.
  • Document the seam in `docs/reference/configuration.md` under a new "diagnostics" subsection.

Refs: dime cycle-1 T2 (code-review) — see PR #241's `AgentConfiguration.cs` H2 fix.

Activity

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