Skip to content

fix: invalid lookup for null context in field resolvers#2585

Merged
Noroth merged 4 commits intomainfrom
ludwig/eng-9060-field-resolver-is-incorrectly-called-on-null-context
Mar 9, 2026
Merged

fix: invalid lookup for null context in field resolvers#2585
Noroth merged 4 commits intomainfrom
ludwig/eng-9060-field-resolver-is-incorrectly-called-on-null-context

Conversation

@Noroth
Copy link
Copy Markdown
Contributor

@Noroth Noroth commented Mar 4, 2026

closes #2573

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for null project query handling to ensure proper null propagation without invoking unnecessary field resolvers
    • Added validation across nested fields, recursive paths, and aliased field scenarios when querying non-existent projects

Checklist

  • I have discussed my proposed changes in an issue and have received approval to proceed.
  • I have followed the coding standards of the project.
  • Tests or benchmarks have been added or updated.
  • Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
  • I have read the Contributors Guide.

@github-actions github-actions bot added the router label Mar 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

Router-nonroot image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-7c1fb84932aebbf73ec8593c82cace6d2f2f99a7-nonroot

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.40%. Comparing base (391bffe) to head (f7513b1).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2585      +/-   ##
==========================================
- Coverage   62.69%   62.40%   -0.30%     
==========================================
  Files         244      244              
  Lines       25776    25775       -1     
==========================================
- Hits        16161    16085      -76     
- Misses       8251     8314      +63     
- Partials     1364     1376      +12     

see 16 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c62441c8-58e7-48f9-afa6-c71aa5ed0bab

📥 Commits

Reviewing files that changed from the base of the PR and between a60de99 and f7513b1.

📒 Files selected for processing (2)
  • router-tests/grpc_subgraph_test.go
  • router-tests/router_plugin_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • router-tests/grpc_subgraph_test.go
  • router-tests/router_plugin_test.go

Walkthrough

Adds test cases validating that querying non-existent projects returns null and prevents field resolver invocation. Tests cover top-level fields, nested subProjects, recursive resolvers, and aliased nested resolvers across two test files with minor formatting adjustments.

Changes

Cohort / File(s) Summary
Null Propagation Tests
router-tests/grpc_subgraph_test.go, router-tests/router_plugin_test.go
Adds three new test cases per file to validate that non-existent projects (id: 999) return null without invoking field resolvers, covering top-level fields, nested subProjects, recursive resolvers, and aliased nested paths. Includes minor formatting adjustment for __typename indentation in existing test blocks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • wundergraph/cosmo#2464: Addresses field-resolver behavior in the same router-tests files with tests for nested resolver invocation semantics.
  • wundergraph/cosmo#2088: Modifies the same test functions (TestGRPCSubgraph and TestRouterPluginRequests) with expanded test coverage.
  • wundergraph/cosmo#2368: Updates the same router-tests files with changes to field resolver behavior validation tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: invalid lookup for null context in field resolvers' accurately describes the main change: preventing field resolver invocation when parent context is null, addressing the core issue.
Linked Issues check ✅ Passed The PR adds test cases validating that querying non-existent projects returns null without invoking field resolvers, which directly addresses issue #2573's requirement to skip field resolver calls on null parent fields.
Out of Scope Changes check ✅ Passed All changes are test additions that directly support the fix for null context handling in field resolvers, with no unrelated modifications present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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/go.mod`:
- Line 34: The call to astnormalization.NewVariablesNormalizer() in
operation_processor.go must be updated to pass the new boolean argument
enableFieldArgumentMapping; locate the call to
astnormalization.NewVariablesNormalizer (near the variables normalization logic
around the operation processing) and change it to
astnormalization.NewVariablesNormalizer(true) or
astnormalization.NewVariablesNormalizer(false) depending on whether you want
field argument mapping enabled for this operation context; ensure any
surrounding code that assumes the previous behavior still works with the chosen
flag.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 24facee6-f58e-4800-adb5-e46a86fab264

📥 Commits

Reviewing files that changed from the base of the PR and between 4c5384d and a4ed067.

⛔ Files ignored due to path filters (2)
  • router-tests/go.sum is excluded by !**/*.sum
  • router/go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • router-tests/go.mod
  • router/go.mod

@Noroth Noroth marked this pull request as ready for review March 5, 2026 13:50
@Noroth Noroth requested review from a team, StarpTech, devsergiy, endigma and jensneuse as code owners March 5, 2026 13:51
@Noroth Noroth requested a review from thisisnithin March 5, 2026 13:51
@Noroth
Copy link
Copy Markdown
Contributor Author

Noroth commented Mar 5, 2026

Waiting on #2589 to build a clean version.

…060-field-resolver-is-incorrectly-called-on-null-context
@github-actions github-actions bot removed the router label Mar 9, 2026
@Noroth Noroth merged commit 854661e into main Mar 9, 2026
23 checks passed
@Noroth Noroth deleted the ludwig/eng-9060-field-resolver-is-incorrectly-called-on-null-context branch March 9, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Field Resolvers Called on Null Parent Fields

2 participants