chore(deps): update graphql-go-tools to fix SIGSEGV in extension filtering#2541
chore(deps): update graphql-go-tools to fix SIGSEGV in extension filtering#2541
Conversation
Fix mutation-during-iteration SIGSEGV in optionallyAllowCustomExtensionProperties. Upstream PR: wundergraph/graphql-go-tools#1402 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdded tests in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
❌ Internal Query Planner CI checks failedThe Internal Query Planner CI checks failed in the celestial repository, and this is going to stop the merge of this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2541 +/- ##
==========================================
+ Coverage 61.00% 61.70% +0.69%
==========================================
Files 239 239
Lines 25423 25423
==========================================
+ Hits 15510 15687 +177
+ Misses 8589 8417 -172
+ Partials 1324 1319 -5 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…SEGV Add tests that reproduce the mutation-during-iteration crash in optionallyAllowCustomExtensionProperties when filtering multiple disallowed extension fields from subgraph error responses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
router-tests/error_handling_test.go (1)
413-423: Prefer sync.WaitGroup.Go for goroutine bookkeeping (Go 1.25+).
This keeps Add/Done management consistent with repo guidance and reduces manual bookkeeping.♻️ Proposed refactor
- done.Add(numOfOperations) + done.Add(numOfOperations) trigger := make(chan struct{}) for i := 0; i < numOfOperations; i++ { - go func() { - ready.Done() - defer done.Done() - <-trigger - res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ - Query: `{ employees { id } }`, - }) - require.Equal(t, `{"errors":[{"message":"Unauthorized","extensions":{"code":"UNAUTHORIZED","statusCode":403}}],"data":{"employees":null}}`, res.Body) - }() + done.Go(func() { + ready.Done() + <-trigger + res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ + Query: `{ employees { id } }`, + }) + require.Equal(t, `{"errors":[{"message":"Unauthorized","extensions":{"code":"UNAUTHORIZED","statusCode":403}}],"data":{"employees":null}}`, res.Body) + }) }Based on learnings: In Go code (Go 1.25+), prefer using sync.WaitGroup.Go(func()) to run a function in a new goroutine, letting the WaitGroup manage Add/Done automatically. Avoid manual wg.Add(1) followed by go func() { defer wg.Done(); ... }() patterns. Apply this guidance across all Go files in the wundergraph/cosmo repository where concurrency is used.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@router-tests/error_handling_test.go` around lines 413 - 423, Replace the manual goroutine launch so the done WaitGroup manages goroutine bookkeeping via WaitGroup.Go; keep ready.Add(numOfOperations) (so each goroutine still calls ready.Done() to signal readiness) but remove done.Add(numOfOperations) and the plain go func() call — instead call done.Go(func() { ready.Done(); defer done.Done(); /* original goroutine body */ }) so the done WaitGroup auto-increments/decrements and you no longer manually call done.Add/Done around the goroutine start.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@router-tests/error_handling_test.go`:
- Around line 421-429: The test spawns a goroutine that calls require.Equal
(which calls FailNow and may panic outside the main test goroutine); instead
have the goroutine send the response body (from xEnv.MakeGraphQLRequestOK with
testenv.GraphQLRequest) over a channel (e.g., respCh) after ready/done
coordination (ready.Done(), defer done.Done(), <-trigger), and move the
assertion into the parent goroutine where you receive from respCh and call
require.Equal(t, expected, received.Body); keep use of ready, done, trigger, and
xEnv.MakeGraphQLRequestOK/testenv.GraphQLRequest/res.Body to locate the code to
change.
---
Nitpick comments:
In `@router-tests/error_handling_test.go`:
- Around line 413-423: Replace the manual goroutine launch so the done WaitGroup
manages goroutine bookkeeping via WaitGroup.Go; keep ready.Add(numOfOperations)
(so each goroutine still calls ready.Done() to signal readiness) but remove
done.Add(numOfOperations) and the plain go func() call — instead call
done.Go(func() { ready.Done(); defer done.Done(); /* original goroutine body */
}) so the done WaitGroup auto-increments/decrements and you no longer manually
call done.Add/Done around the goroutine start.
ee185c3 to
d8ad12c
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
router-tests/error_handling_test.go (1)
494-512: Usesync.WaitGroup.Gofor goroutine launch.
The repository uses Go 1.25, which providesWaitGroup.Gothat automatically manages goroutine lifecycle. This simplifies thedonewaitgroup while keepingreadyas-is.♻️ Suggested refactor
- ready.Add(numOfOperations) - done.Add(numOfOperations) + ready.Add(numOfOperations) trigger := make(chan struct{}) for i := 0; i < numOfOperations; i++ { - go func() { - ready.Done() - defer done.Done() - <-trigger - res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ - Query: `{ employees { id } }`, - }) - results <- res.Body - }() + done.Go(func() { + ready.Done() + <-trigger + res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ + Query: `{ employees { id } }`, + }) + results <- res.Body + }) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@router-tests/error_handling_test.go` around lines 494 - 512, Replace the manual goroutine lifecycle management using the done WaitGroup with WaitGroup.Go: keep numOfOperations and ready as-is (ready.Add(numOfOperations)), remove the done variable and its Add/Done/Wait usage, introduce a new waitgroup (e.g., wg := sync.WaitGroup{}), and launch each worker with wg.Go(func() { ready.Done(); <-trigger; res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ Query: `{ employees { id } }`, }); results <- res.Body }); then call wg.Wait() after closing the trigger; this uses WaitGroup.Go to auto-manage goroutine completion and drops the explicit defer done.Done.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@router-tests/error_handling_test.go`:
- Around line 349-353: The HTTP handler goroutines in the test use
require.NoError (inside the http.HandlerFunc closure) which can call FailNow and
panic when invoked off the main test goroutine; replace those require.NoError
calls with non-fatal reporting (e.g., t.Error or t.Errorf) or send errors back
to the main test goroutine via a channel and assert there; update every
occurrence of require.NoError inside the handler closures (the http.HandlerFunc
in this test) to use t.Error*/channel reporting so failures are reported safely
from the main test goroutine.
---
Nitpick comments:
In `@router-tests/error_handling_test.go`:
- Around line 494-512: Replace the manual goroutine lifecycle management using
the done WaitGroup with WaitGroup.Go: keep numOfOperations and ready as-is
(ready.Add(numOfOperations)), remove the done variable and its Add/Done/Wait
usage, introduce a new waitgroup (e.g., wg := sync.WaitGroup{}), and launch each
worker with wg.Go(func() { ready.Done(); <-trigger; res :=
xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{ Query: `{ employees { id } }`,
}); results <- res.Body }); then call wg.Wait() after closing the trigger; this
uses WaitGroup.Go to auto-manage goroutine completion and drops the explicit
defer done.Done.
…ltering Three new test cases with 3 allowed fields: - all subgraph fields match allowed list (nothing filtered) - subgraph has extra fields beyond allowed list (some filtered) - no subgraph fields match allowed list (all filtered) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d8ad12c to
62d5e2b
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Fixes ENG-8985
graphql-go-toolsto commit c96ac9e6f088 to fix mutation-during-iteration SIGSEGV inoptionallyAllowCustomExtensionPropertiesUpstream PR: wundergraph/graphql-go-tools#1402
🤖 Generated with Claude Code
Summary by CodeRabbit