feat: config batching and type-annotated errors#17
Conversation
Config[T] now annotates errors with the type name via reflect so apps no longer need per-call error wrapping. ConfigAll runs a sequence of config loaders and stops on the first error. Part 1 of #14 — config batching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wintermute-zbz
left a comment
There was a problem hiding this comment.
Review — #17
Verdict: APPROVE
Two additions: type-annotated config errors and ConfigAll batch helper. Both correct.
Findings
config.go:23 — reflect.TypeOf(cfg).Name() returns empty string for pointer types.
Not blocking. Config[T] passes &cfg to fig.LoadContext, so T must be a struct value — pointer types would fail at the fig layer before the error annotation runs. Self-protecting. Noting for awareness only.
Assessment
- Error wrapping uses
%wcorrectly. Chain preserved. ConfigAllis minimal — sequential execution, stops on first error, zero-allocation empty case. Nothing to trim.- Tests cover: type name in error message, happy path batching, short-circuit on first error, empty variadic. Good coverage.
reflectimport is new to the codebase. Cost is justified — no other way to getT's name at runtime in Go generics.- No security surface change. No new dependencies.
Clean.
| } | ||
| if err := fig.LoadContext(ctx, &cfg, opts...); err != nil { | ||
| return err | ||
| return fmt.Errorf("config %s: %w", reflect.TypeOf(cfg).Name(), err) |
There was a problem hiding this comment.
if we are using reflection we might as well ingest via sentinel - right here I think we should be running sentinel.InspectT so that we don't use reflection directly and the type metadata is available to the service as a whole
There was a problem hiding this comment.
Fixed — switched to sentinel.InspectT so the type metadata is cached in sentinel's registry and available to the service. Error messages now use FQDN. reflect import dropped.
Replaces reflect.TypeOf(cfg).Name() with sentinel.Inspect[T]() so type metadata is cached and available to the service. Error messages now use FQDN instead of bare type name. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
wintermute-zbz
left a comment
There was a problem hiding this comment.
Re-review — #17
Verdict: APPROVE
New commit swaps reflect.TypeOf(cfg).Name() for sentinel.Inspect[T]().FQDN. Better — uses the ecosystem's own type metadata instead of the reflect package. No new dependency (sentinel already in go.mod). reflect import removed.
Previous finding (empty name for pointer types) is resolved — sentinel handles this through its own type introspection.
Tests still pass. Clean.
Summary
Config[T]now annotates errors with the type name viareflect.TypeOf, eliminating per-callfmt.Errorfwrapping in application bootstrapConfigAll(loaders ...func() error) error— runs config loaders sequentially, stops on first errorPart 1 of #14 — config batching.
Test plan
requiredConfig)🤖 Generated with Claude Code