Skip to content

fix(join): signature join point miscounts parameters declared with a shared type - #964

Merged
darccio merged 2 commits into
DataDog:mainfrom
vignesh2027:fix/signature-grouped-params
Nov 25, 2026
Merged

darccio merged 2 commits into
DataDog:mainfrom
vignesh2027:fix/signature-grouped-params

Conversation

@vignesh2027

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the signature join point so it counts one type per declared name when it compares a function against the expected args and returns.

The matcher compared len(expected) to the number of fields in the parameter list. Go groups names that share a type into one field, so func(a, b string) has a single field. With args: [string, string] the aspect never matched that function, and with args: [string] it matched it by mistake. Named results such as (x, y int) had the same problem.

The change expands each field into one entry per name (or one for an unnamed field) before comparing, in order.

Motivation

An aspect that selects functions by an exact signature silently skipped any function whose parameters share a type, and could pick up functions with more parameters than it asked for.

Testing

Added TestSignatureEvaluate, which covers grouped parameters, grouped named results, mixed grouped and separate parameters, ordering and unnamed parameters. The grouped cases fail without the change. go test -race ./internal/injector/... and golangci-lint run pass.

…shared type

The signature option compared the number of expected types to the number of
fields in the parameter and result lists. A field that names several
parameters, such as the a, b in func(a, b string), is a single field, so
signature args [string, string] never matched that function while args
[string] matched it.

Count one type per declared name instead, for both arguments and results.
@vignesh2027
vignesh2027 requested a review from a team as a code owner November 22, 2026 18:30
@darccio
darccio enabled auto-merge November 25, 2026 11:21
@darccio
darccio added this pull request to the merge queue Nov 25, 2026
Merged via the queue into DataDog:main with commit 559e548 Nov 25, 2026
31 checks passed
@vignesh2027

Copy link
Copy Markdown
Contributor Author

Really appreciate the thorough review on this one. Your point about the nil field lists and the combined signature cases made the tests far more honest than what I first sent, and it's great to see the grouped parameter fix land. Thanks for taking the time.

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.

2 participants