Skip to content

feat(trace): fall back to binary scope when project scope is unsupported#115

Open
dodoazzurro wants to merge 1 commit into
mainfrom
feat/project-scope-fallback
Open

feat(trace): fall back to binary scope when project scope is unsupported#115
dodoazzurro wants to merge 1 commit into
mainfrom
feat/project-scope-fallback

Conversation

@dodoazzurro

Copy link
Copy Markdown
Collaborator

Why

When --scope=project is used against a binary that does not carry Go build info (e.g. built as command-line-arguments, a non-Go binary, or one without a .go_buildinfo section), xcover would hard-fail with:

failed to resolve functions: failed to detect Go module path (is this a Go binary?): binary was built as command-line-arguments

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 ErrProjectScopeUnsupported that GoProjectResolver returns whenever build info is missing or unusable. defaultResolver wraps the project resolver with withProjectFallback, which catches that sentinel, logs a warning, and delegates to SymbolTableResolver.

Any other error from the primary resolver is still propagated as-is, so genuine failures (e.g. empty symbol table) are not swallowed.

How

  • ErrProjectScopeUnsupported sentinel in tracee_errors.go - inspectable via errors.Is
  • withProjectFallback(primary, fallback, logger) - a pure resolver wrapper, easy to test in isolation and composable if other scope types need the same pattern later
  • defaultResolver in tracee.go builds the fallback chain only for ScopeProject; explicit custom resolvers passed via WithResolver are unaffected
  • Unit tests for all three paths: primary success, fallback on unsupported, propagation of unrelated errors

@dodoazzurro dodoazzurro changed the base branch from userspace to main June 11, 2026 21:04
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.
@dodoazzurro dodoazzurro force-pushed the feat/project-scope-fallback branch from c4b1d37 to ad123dd Compare June 11, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant