Repository navigation
fix: DI interface follow-ups before v0.8.0 - #35
Merged
Merged
Conversation
addArg registers each value under its dynamic type, so the registry never has an interface key and the exact lookup for an interface parameter could not hit. Correct the doc line that promised it. Claude-Session: https://claude.ai/code/session_01Dp3Jmu2ePyCME2yG9yd672
Before interface filling, WithArgs(&s) with s of interface type Svc filled a Svc parameter through the pointer-to-value rule. The new interface path skipped it, since *Svc doesn't implement Svc. Look for a registered *Iface first: that restores the old behaviour and gives a way to pick one implementation when several are registered. Docs: Mount's ambiguity check covers Props and extended ServeHTTP only (Page/component params fail at request time), the error names every implementation, and the check knows the writer only as http.ResponseWriter. Claude-Session: https://claude.ai/code/session_01Dp3Jmu2ePyCME2yG9yd672
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
=======================================
Coverage 95.21% 95.21%
=======================================
Files 16 16
Lines 1547 1547
=======================================
Hits 1473 1473
Misses 44 44
Partials 30 30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups to #34, which was squash-merged before these landed. Found by the eos agent and an adversarial review.
Fixes
fa8ca2f). Registrations are keyed by their dynamic type, so the exact-interface-key lookup ingetArgcould never hit. The doc line promising "exact registration wins" for interfaces is corrected.var s Svc = &A{}; WithArgs(&s)filledProps(s Svc)through the pointer-to-value rule.*Svcdoesn't implementSvc, so it returned "not found". Worse, if an implementation was also registered, the parameter silently got that implementation instead.getArgnow looks for a registered*Ifacefirst. That also gives a way to choose one implementation when several are registered, without touching the handler.TestInjection_pointerToInterfaceIsUsedFirst.Docs (review findings)
Mountambiguity check coversPropsand extendedServeHTTPonly.Init/MiddlewaresfailMountanyway, andPage/component parameters fail at request time.http.ResponseWriter.Props(sw io.StringWriter)with two StringWriters registered failsMount, although the real writer would fill it.http.ResponseWriterorio.Writer.Left as is (intended or contrived)
anyparameter beyond the request values now takes a lone registration, and with two registrations it failsMount. It used to be "not found".RenderTargetisn't modelled. A broken page can passMount; a working one is never rejected.go test ./..., golangci-lint and gopls are clean.https://claude.ai/code/session_01Dp3Jmu2ePyCME2yG9yd672