Skip to content

Conversation

@Aenimus
Copy link
Member

@Aenimus Aenimus commented Oct 15, 2025

Summary by CodeRabbit

  • New Features

    • Error reports now include structured context (existing parent data, incoming type, subgraph name) for clearer diagnostics and richer payloads.
    • New public type exposed to represent the structured error parameters.
  • Bug Fixes

    • Detects and aborts invalid merges between interface and non-interface definitions, emitting a clear fatal error.
    • Improved error formatting now quotes expected type names for clarity.
  • Tests

    • Expanded tests and fixtures covering interface vs. object conflicts and the new structured error payloads.

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.

@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

Replaced positional incompatibleParentKindMergeError with object-parameter incompatibleParentTypeMergeError, added IncompatibleParentTypeMergeErrorParams and SubgraphName usage, updated federation factory signature/guards to use typed subgraph names, adjusted error text/exports, and updated tests and control-plane tests to the new error shape.

Changes

Cohort / File(s) Summary
Errors API & types
composition/src/errors/errors.ts, composition/src/errors/types.ts
Replaced incompatibleParentKindMergeError with incompatibleParentTypeMergeError that accepts IncompatibleParentTypeMergeErrorParams; added and exported IncompatibleParentTypeMergeErrorParams; added interfaceObject constant; updated imports/exports to include SubgraphName; adjusted related error messages.
Federation factory
composition/src/v1/federation/federation-factory.ts
Changed upsertParentDefinitionData to accept SubgraphName; switched parent-merge error calls to incompatibleParentTypeMergeError({ existingData, incomingNodeType, incomingSubgraphName }); added guard to block merging an Interface into a non-interface target.
Composition tests
composition/tests/v1/entity-interface.test.ts, composition/tests/v1/federation-factory.test.ts
Updated tests to import/use incompatibleParentTypeMergeError and new DefinitionData types; added Kind from graphql; constructed existingData objects and updated expectations to the structured error payload.
Control plane tests
controlplane/test/composition-errors.test.ts
Replaced incompatibleParentKindMergeError with incompatibleParentTypeMergeError; added Kind import and ObjectDefinitionData/SubgraphName types; adapted assertions to the new structured error object format.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly indicates that the pull request enhances the error handling for incompatible types, directly reflecting the primary changes replacing and improving legacy type merge errors. It is clear, specific to the main change, and follows a conventional commit style without unnecessary detail.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fafebb and adb8a9e.

📒 Files selected for processing (2)
  • composition/src/errors/errors.ts (3 hunks)
  • controlplane/test/composition-errors.test.ts (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
controlplane/test/composition-errors.test.ts (4)
composition/src/errors/errors.ts (2)
  • incompatibleMergedTypesError (70-80)
  • incompatibleParentTypeMergeError (344-358)
composition/src/utils/string-constants.ts (3)
  • STRING_SCALAR (140-140)
  • INT_SCALAR (74-74)
  • INTERFACE (75-75)
composition/src/types/types.ts (1)
  • SubgraphName (9-9)
composition/src/schema-building/types.ts (1)
  • ObjectDefinitionData (174-191)
composition/src/errors/errors.ts (3)
composition/src/errors/types.ts (1)
  • IncompatibleParentTypeMergeErrorParams (38-42)
composition/src/utils/utils.ts (1)
  • kindToNodeType (72-141)
composition/src/resolvability-graph/constants/string-constants.ts (1)
  • QUOTATION_JOIN (8-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: build_push_image
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./events)
  • GitHub Check: image_scan (nonroot)
  • GitHub Check: build_test
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (go)
  • GitHub Check: build_test
🔇 Additional comments (2)
controlplane/test/composition-errors.test.ts (1)

349-359: LGTM! Past review concern addressed.

The test now correctly calls incompatibleParentTypeMergeError with the object-parameter form. The existingData stub includes the required fields (name, kind, subgraphNames), and the parameters match the new API signature.

composition/src/errors/errors.ts (1)

344-358: LGTM! Clean implementation.

The function correctly:

  • Destructures the structured parameters
  • Converts existingData.subgraphNames Set to an array for pluralization and joining
  • Uses kindToNodeType helper to map the existing Kind to a readable string
  • Falls back to interfaceObject constant when incomingNodeType is not provided
  • Constructs a clear, informative error message

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

@github-actions
Copy link

github-actions bot commented Oct 15, 2025

Router-nonroot image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-3427383403b1c946529d5a60d8b386ac9077fdd9-nonroot

Copy link

@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

🧹 Nitpick comments (1)
composition/src/errors/errors.ts (1)

344-358: Approve the refactor; consider simplifying array creation.

The refactor from positional parameters to an object-parameter API improves maintainability and clarity. The error message construction correctly handles both explicit incomingNodeType and the Interface Object fallback case.

On line 349, consider using a more concise array creation:

-  const existingSubgraphNames = new Array<SubgraphName>(...existingData.subgraphNames);
+  const existingSubgraphNames = Array.from(existingData.subgraphNames);

or

-  const existingSubgraphNames = new Array<SubgraphName>(...existingData.subgraphNames);
+  const existingSubgraphNames = [...existingData.subgraphNames];
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7c05cb and 6e28b2c.

📒 Files selected for processing (6)
  • composition/src/errors/errors.ts (4 hunks)
  • composition/src/errors/types.ts (2 hunks)
  • composition/src/v1/federation/federation-factory.ts (4 hunks)
  • composition/tests/v1/entity-interface.test.ts (4 hunks)
  • composition/tests/v1/federation-factory.test.ts (3 hunks)
  • controlplane/test/composition-errors.test.ts (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
composition/src/errors/types.ts (2)
composition/src/schema-building/types.ts (1)
  • ParentDefinitionData (242-248)
composition/src/types/types.ts (1)
  • SubgraphName (9-9)
composition/tests/v1/entity-interface.test.ts (8)
composition/tests/utils/utils.ts (1)
  • federateSubgraphsFailure (49-57)
composition/src/router-compatibility-version/router-compatibility-version.ts (1)
  • ROUTER_COMPATIBILITY_VERSION_ONE (3-3)
composition/src/utils/string-constants.ts (2)
  • INTERFACE (75-75)
  • OBJECT (104-104)
composition/src/types/types.ts (1)
  • SubgraphName (9-9)
composition/src/schema-building/types.ts (2)
  • InterfaceDefinitionData (157-172)
  • ObjectDefinitionData (174-191)
composition/src/errors/errors.ts (1)
  • incompatibleParentTypeMergeError (344-358)
composition/src/subgraph/types.ts (1)
  • Subgraph (11-15)
composition/src/ast/utils.ts (1)
  • parse (272-274)
composition/tests/v1/federation-factory.test.ts (5)
composition/src/utils/string-constants.ts (3)
  • OBJECT (104-104)
  • SCALAR (124-124)
  • INPUT_OBJECT (71-71)
composition/src/schema-building/types.ts (3)
  • ScalarDefinitionData (209-219)
  • ObjectDefinitionData (174-191)
  • InputObjectDefinitionData (120-132)
composition/src/errors/errors.ts (2)
  • incompatibleParentTypeMergeError (344-358)
  • noBaseDefinitionForExtensionError (158-163)
composition/tests/utils/utils.ts (1)
  • federateSubgraphsFailure (49-57)
composition/src/router-compatibility-version/router-compatibility-version.ts (1)
  • ROUTER_COMPATIBILITY_VERSION_ONE (3-3)
controlplane/test/composition-errors.test.ts (2)
composition/src/errors/errors.ts (2)
  • incompatibleMergedTypesError (70-80)
  • incompatibleParentTypeMergeError (344-358)
composition/src/utils/string-constants.ts (4)
  • STRING_SCALAR (140-140)
  • INT_SCALAR (74-74)
  • OBJECT (104-104)
  • INTERFACE (75-75)
composition/src/errors/errors.ts (4)
composition/src/errors/types.ts (1)
  • IncompatibleParentKindMergeErrorParams (38-42)
composition/src/resolvability-graph/types/types.ts (1)
  • SubgraphName (13-13)
composition/src/utils/utils.ts (1)
  • kindToNodeType (72-141)
composition/src/resolvability-graph/constants/string-constants.ts (1)
  • QUOTATION_JOIN (8-8)
composition/src/v1/federation/federation-factory.ts (4)
composition/src/schema-building/types.ts (1)
  • ParentDefinitionData (242-248)
composition/src/resolvability-graph/types/types.ts (1)
  • SubgraphName (13-13)
composition/src/errors/errors.ts (1)
  • incompatibleParentTypeMergeError (344-358)
composition/src/utils/utils.ts (1)
  • kindToNodeType (72-141)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: image_scan (nonroot)
  • GitHub Check: build_push_image
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: build_test
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: build_push_image
  • GitHub Check: build_test
🔇 Additional comments (4)
composition/src/errors/errors.ts (4)

10-10: LGTM! Import supports the refactored error function.

The IncompatibleParentKindMergeErrorParams type import is correctly added to support the new object-parameter signature of incompatibleParentTypeMergeError.


43-43: LGTM! Type imports support the refactored function.

The imports of NodeType, SubgraphName, and TypeName are correctly added to support the new function signature and typing.


342-342: LGTM! Clear constant for Interface Object description.

The interfaceObject constant provides a well-formatted description for use in error messages when the incoming node type is not explicitly provided.


383-383: LGTM! Formatting consistency improvement.

Adding quotes around expectedTypeString improves consistency with other error messages in the file and makes the error output clearer.

Copy link

@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: 0

🧹 Nitpick comments (1)
composition/src/errors/errors.ts (1)

349-356: Prefer array literal copy for readability.

new Array(...existingData.subgraphNames) works, but it reads like the length-based constructor and will misbehave if anything ever supplies a numeric value. [...existingData.subgraphNames] or Array.from(existingData.subgraphNames) communicates the intent to clone an iterable without that footgun. Consider switching to one of those forms.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e28b2c and 7fafebb.

📒 Files selected for processing (2)
  • composition/src/errors/errors.ts (4 hunks)
  • composition/src/errors/types.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • composition/src/errors/types.ts
🧰 Additional context used
🧬 Code graph analysis (1)
composition/src/errors/errors.ts (4)
composition/src/errors/types.ts (1)
  • IncompatibleParentTypeMergeErrorParams (38-42)
composition/src/types/types.ts (1)
  • SubgraphName (9-9)
composition/src/utils/utils.ts (1)
  • kindToNodeType (72-141)
composition/src/resolvability-graph/constants/string-constants.ts (1)
  • QUOTATION_JOIN (8-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: build_push_image
  • GitHub Check: integration_test (./events)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: build_test
  • GitHub Check: Analyze (go)
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: build_test

@Aenimus Aenimus enabled auto-merge (squash) October 16, 2025 10:22
@Aenimus Aenimus merged commit 498bd47 into main Oct 16, 2025
41 of 43 checks passed
@Aenimus Aenimus deleted the david/eng-8306-improve-incompatible-types-error branch October 16, 2025 13:42
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.

4 participants