feat(trace): fall back to binary scope when project scope is unsupported#115
Open
dodoazzurro wants to merge 1 commit into
Open
feat(trace): fall back to binary scope when project scope is unsupported#115dodoazzurro wants to merge 1 commit into
dodoazzurro wants to merge 1 commit into
Conversation
When a binary lacks the Go build info needed for project-scoped function resolution (e.g. built as command-line-arguments, stripped, or not a Go binary), GoProjectResolver now returns the typed sentinel ErrProjectScopeUnsupported instead of a generic error. defaultResolver wraps the GoProjectResolver with withProjectFallback, which catches that sentinel, logs a warning, and delegates to SymbolTableResolver. All other errors are propagated as-is. This prevents xcover from hard-failing when --scope=project is used against a binary that doesn't support it. Unit tests cover: primary success, fallback on ErrProjectScopeUnsupported, and error propagation for unrelated failures.
c4b1d37 to
ad123dd
Compare
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.
Why
When
--scope=projectis used against a binary that does not carry Go build info (e.g. built ascommand-line-arguments, a non-Go binary, or one without a.go_buildinfosection), xcover would hard-fail with:Project scoping is best-effort: if the binary does not support it, binary scope is the right fallback rather than an outright failure.
What
Introduces a typed sentinel
ErrProjectScopeUnsupportedthatGoProjectResolverreturns whenever build info is missing or unusable.defaultResolverwraps the project resolver withwithProjectFallback, which catches that sentinel, logs a warning, and delegates toSymbolTableResolver.Any other error from the primary resolver is still propagated as-is, so genuine failures (e.g. empty symbol table) are not swallowed.
How
ErrProjectScopeUnsupportedsentinel intracee_errors.go- inspectable viaerrors.IswithProjectFallback(primary, fallback, logger)- a pure resolver wrapper, easy to test in isolation and composable if other scope types need the same pattern laterdefaultResolverintracee.gobuilds the fallback chain only forScopeProject; explicit custom resolvers passed viaWithResolverare unaffected