Skip to content

fix: short-circuit before propagating non-fully validated resolvabili…#2759

Merged
Aenimus merged 4 commits intomainfrom
david/eng-9320-short-circuit-before-unvalidated-error-propagation
Apr 13, 2026
Merged

fix: short-circuit before propagating non-fully validated resolvabili…#2759
Aenimus merged 4 commits intomainfrom
david/eng-9320-short-circuit-before-unvalidated-error-propagation

Conversation

@Aenimus
Copy link
Copy Markdown
Member

@Aenimus Aenimus commented Apr 13, 2026

…ty errors

Summary by CodeRabbit

  • Bug Fixes

    • Improved resolvability error reporting for shared root fields: clearer, more specific messages about missing resolution routes and when only inaccessible selections remain.
  • Refactor

    • Reworked internal ancestor/validation flow to simplify error generation and early-exit behavior for faster, clearer validation outcomes.
  • Tests

    • Added tests covering edge cases for shared-root field resolvability, including inaccessible selection scenarios.

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/docs-website.
  • I have read the Contributors Guide.

Open Source AI Manifesto

This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • composition-go/index.global.js
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 51727142-0090-40af-9b1f-4473413b4464

📥 Commits

Reviewing files that changed from the base of the PR and between b9df341 and ffa810a.

📒 Files selected for processing (1)
  • composition-go/index.global.js

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Refactors shared-entity root-field resolvability handling: removes inline shared-entity error construction, adds getEntityAncestorCollection(...), introduces FieldCoords and GetEntityReasonsParams types, restructures error-reason generation via new helper functions, and updates tests to use SubgraphName and new ancestor mapping.

Changes

Cohort / File(s) Summary
Core Logic Refactor
composition/src/resolvability-graph/graph.ts
Removed getSharedEntityResolvabilityErrors(...); added getEntityAncestorCollection(entityNodeNames: Set<NodeName>): EntityAncestorCollection; updated validateSharedRootFieldEntities to early-return when no unresolvable paths and to call the new ancestor-collection-based error generation.
Type System Updates
composition/src/resolvability-graph/types/types.ts, composition/src/resolvability-graph/utils/types/params.ts, composition/src/resolvability-graph/utils/types/types.ts
Added exported FieldCoords = \${TypeName}.${FieldName}`and changedRootFieldData.coordstoFieldCoords. Added GetEntityReasonsParamstype. ExtendedEntityAncestorCollectionwithsourceSubgraphNamesBySatisfiedFieldSet: Map<string, Array>`.
Error Message Generation Refactor
composition/src/resolvability-graph/utils/utils.ts
Added getSelfEntityReasons and getAncestorEntityReasons helpers; refactored generateSharedResolvabilityErrorReasons to compute coords, determine isEntity, and delegate to the new helpers; adjusted wording/formatting of shared-entity resolvability messages.
Test Suite Updates
composition/tests/v1/resolvability.test.ts
Updated fixtures and constructors to use SubgraphName and Set<SubgraphName>; extended EntityAncestorCollection fixtures with sourceSubgraphNamesBySatisfiedFieldSet; added new test case for fully-validated inaccessible selections and three subgraphs (kaaa, kaab, kaac).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly addresses the main objective: short-circuiting before propagating non-fully validated resolvability errors, which aligns with the changes that add early returns and refactor error generation logic.

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


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

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 94.69027% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.72%. Comparing base (284886f) to head (ffa810a).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
composition/src/resolvability-graph/graph.ts 88.57% 4 Missing ⚠️
composition/src/resolvability-graph/utils/utils.ts 97.40% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2759       +/-   ##
===========================================
- Coverage   64.45%   45.72%   -18.73%     
===========================================
  Files         306     1036      +730     
  Lines       43621   139222    +95601     
  Branches     4690     8667     +3977     
===========================================
+ Hits        28114    63656    +35542     
- Misses      15485    73824    +58339     
- Partials       22     1742     +1720     
Files with missing lines Coverage Δ
composition/src/resolvability-graph/types/types.ts 100.00% <ø> (ø)
...tion/src/resolvability-graph/utils/types/params.ts 100.00% <100.00%> (ø)
composition/src/resolvability-graph/utils/utils.ts 98.97% <97.40%> (ø)
composition/src/resolvability-graph/graph.ts 94.13% <88.57%> (ø)

... and 726 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

Router image scan failed

❌ Security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-756f3e87cab1bf1774e56166ff81db92fa39ec6c

Please check the security vulnerabilities found in the PR.

If you believe this is a false positive, please add the vulnerability to the .trivyignore file and re-run the scan.

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 `@composition/src/resolvability-graph/graph.ts`:
- Around line 342-346: The condition checking walker.unresolvablePaths is wrong
because Set.size is never negative; update the short-circuit in the block that
currently reads `if (walker.unresolvablePaths.size < 0)` to check for emptiness
(e.g., `walker.unresolvablePaths.size < 1` or `=== 0`) so the early return {
success: true } executes when there are no unresolvable paths; locate this in
graph.ts near the walker usage and adjust the comparison accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a3a6a96f-b96e-4c31-83b5-ba1ac0e5aeff

📥 Commits

Reviewing files that changed from the base of the PR and between a403046 and 62f6e42.

📒 Files selected for processing (7)
  • composition-go/index.global.js
  • composition/src/resolvability-graph/graph.ts
  • composition/src/resolvability-graph/types/types.ts
  • composition/src/resolvability-graph/utils/types/params.ts
  • composition/src/resolvability-graph/utils/types/types.ts
  • composition/src/resolvability-graph/utils/utils.ts
  • composition/tests/v1/resolvability.test.ts

Comment thread composition/src/resolvability-graph/graph.ts Outdated
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.

🧹 Nitpick comments (1)
composition/src/resolvability-graph/graph.ts (1)

502-503: Consider adding a guard for empty entityNodeNames.

The non-null assertion ! on line 503 assumes entityNodeNames is never empty. If it is, getFirstEntry returns undefined and .split() will throw a TypeError.

While the calling context likely ensures non-empty sets, a defensive check would make this more robust.

🛡️ Suggested defensive handling
 getEntityAncestorCollection(entityNodeNames: Set<NodeName>): EntityAncestorCollection {
-  const typeName = getFirstEntry(entityNodeNames)!.split(LITERAL_PERIOD)[1];
+  const firstEntry = getFirstEntry(entityNodeNames);
+  if (!firstEntry) {
+    throw new Error('Fatal: entityNodeNames cannot be empty');
+  }
+  const typeName = firstEntry.split(LITERAL_PERIOD)[1];
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@composition/src/resolvability-graph/graph.ts` around lines 502 - 503, In
getEntityAncestorCollection, avoid the unsafe non-null assertion on
getFirstEntry(entityNodeNames) by first guarding for an empty entityNodeNames
Set: check if entityNodeNames.size === 0 and handle it (e.g., throw a clear
error or return an appropriate empty EntityAncestorCollection) before calling
getFirstEntry(...). Keep the rest of the logic that splits the returned node
name by LITERAL_PERIOD and uses typeName unchanged; reference function
getEntityAncestorCollection, helper getFirstEntry, parameter entityNodeNames,
and constant LITERAL_PERIOD when applying this fix.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@composition/src/resolvability-graph/graph.ts`:
- Around line 502-503: In getEntityAncestorCollection, avoid the unsafe non-null
assertion on getFirstEntry(entityNodeNames) by first guarding for an empty
entityNodeNames Set: check if entityNodeNames.size === 0 and handle it (e.g.,
throw a clear error or return an appropriate empty EntityAncestorCollection)
before calling getFirstEntry(...). Keep the rest of the logic that splits the
returned node name by LITERAL_PERIOD and uses typeName unchanged; reference
function getEntityAncestorCollection, helper getFirstEntry, parameter
entityNodeNames, and constant LITERAL_PERIOD when applying this fix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6878389c-c915-463c-af9f-510f465f2127

📥 Commits

Reviewing files that changed from the base of the PR and between 62f6e42 and b9df341.

📒 Files selected for processing (1)
  • composition/src/resolvability-graph/graph.ts

@Aenimus Aenimus merged commit b39e30e into main Apr 13, 2026
40 of 42 checks passed
@Aenimus Aenimus deleted the david/eng-9320-short-circuit-before-unvalidated-error-propagation branch April 13, 2026 17:40
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