Skip to content

Conversation

@endigma
Copy link
Member

@endigma endigma commented Jul 8, 2025

Summary by CodeRabbit

Summary by CodeRabbit

  • Tests
    • Added tests to verify error propagation behavior with allowed and disallowed extension fields in different modes.
  • Chores
    • Updated a dependency to a newer version for improved compatibility.
  • New Features
    • Introduced configurable options for subgraph error propagation, including a new setting to allow all extension fields.
    • Enhanced configuration schema and defaults to support refined error extension field controls.

Depends on wundergraph/graphql-go-tools#1217

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 Jul 8, 2025

Walkthrough

A new test function was introduced to validate error propagation behavior regarding allowed extension fields in GraphQL subgraph errors, covering both wrapped and passthrough modes with different configuration flags. The dependency on github.com/wundergraph/graphql-go-tools/v2 was updated to a newer pseudo-version in two Go module files. Configuration structs and schema were extended to support a new AllowAllExtensionFields option controlling propagation of all extension fields. Corresponding config files were updated to include this new option and adjust environment variable tagging.

Changes

Files Change Summary
router-tests/error_handling_test.go Added TestAllowedExtensions to test subgraph error propagation with allowed extension fields in wrapped and passthrough modes.
router-tests/go.mod, router/go.mod Updated github.com/wundergraph/graphql-go-tools/v2 dependency from v2.0.0-rc.202 to v2.0.0-rc.203.
router/core/executor.go Added AllowAllErrorExtensionFields field to resolve.ResolverOptions from subgraph error propagation config; moved ApolloRouterCompatibilitySubrequestHTTPError assignment out of nested struct.
router/pkg/config/config.go Added AllowAllExtensionFields bool field to SubgraphErrorPropagationConfiguration; updated env tags to remove prefix and added envPrefix:"SUBGRAPH_ERROR_PROPAGATION_" tag on nested config struct.
router/pkg/config/config.schema.json Added allow_all_extension_fields boolean property with default false to subgraph error propagation schema.
router/pkg/config/fixtures/full.yaml Added new subgraph_error_propagation config block with multiple fields including allow_all_extension_fields; minor YAML string quote style change.
router/pkg/config/testdata/config_defaults.json Added "AllowAllExtensionFields": false to SubgraphErrorPropagation defaults.
router/pkg/config/testdata/config_full.json Modified SubgraphErrorPropagation config values: changed mode, omitted extensions, added AllowAllExtensionFields: true, and updated allowed extension fields list.

📜 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 360baf3 and ca82696.

⛔ 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 (9)
  • router-tests/error_handling_test.go (1 hunks)
  • router-tests/go.mod (1 hunks)
  • router/core/executor.go (2 hunks)
  • router/go.mod (1 hunks)
  • router/pkg/config/config.go (2 hunks)
  • router/pkg/config/config.schema.json (1 hunks)
  • router/pkg/config/fixtures/full.yaml (2 hunks)
  • router/pkg/config/testdata/config_defaults.json (1 hunks)
  • router/pkg/config/testdata/config_full.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • router/go.mod
  • router-tests/go.mod
  • router/pkg/config/testdata/config_defaults.json
  • router/core/executor.go
  • router/pkg/config/testdata/config_full.json
  • router/pkg/config/fixtures/full.yaml
  • router/pkg/config/config.schema.json
  • router/pkg/config/config.go
🔇 Additional comments (1)
router-tests/error_handling_test.go (1)

222-335: Excellent test coverage for the new AllowAllExtensionFields feature!

The test function comprehensively validates the new AllowAllExtensionFields configuration option with proper coverage of both wrapped and passthrough modes. The test structure is well-organized, follows existing patterns, and correctly validates the extension field filtering behavior.

Key strengths:

  • Consistent middleware setup across all subtests for reliable comparison
  • Proper testing of both error propagation modes
  • Clear validation of extension field filtering vs. passthrough behavior
  • Good use of descriptive test names that explain the expected behavior
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the router label Jul 8, 2025
@endigma endigma changed the title feat: don't strip extensions from errors in passthrough mode feat: disable error extension filtering in passthrough mode Jul 8, 2025
@github-actions
Copy link

github-actions bot commented Jul 8, 2025

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-f718b5b8bf50a5c66c2232ceec28d7d92c6d9e22

@endigma endigma marked this pull request as draft July 8, 2025 14:18
Copy link
Contributor

@SkArchon SkArchon left a comment

Choose a reason for hiding this comment

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

New Tests LGTM, need tests to pass though

@endigma endigma force-pushed the jesse/eng-7495-custom-extension-field-stripping branch from 7d0f3cf to 36e954c Compare July 9, 2025 09:51
@endigma endigma marked this pull request as ready for review July 9, 2025 09:53
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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8cf121 and ecfc4dc.

⛔ 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 (9)
  • router-tests/error_handling_test.go (1 hunks)
  • router-tests/go.mod (1 hunks)
  • router/core/executor.go (1 hunks)
  • router/go.mod (1 hunks)
  • router/pkg/config/config.go (2 hunks)
  • router/pkg/config/config.schema.json (1 hunks)
  • router/pkg/config/fixtures/full.yaml (2 hunks)
  • router/pkg/config/testdata/config_defaults.json (1 hunks)
  • router/pkg/config/testdata/config_full.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • router/pkg/config/testdata/config_defaults.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • router/go.mod
  • router-tests/go.mod
  • router-tests/error_handling_test.go
🧰 Additional context used
🧠 Learnings (1)
router/pkg/config/config.schema.json (2)

undefined

<retrieved_learning>
Learnt from: SkArchon
PR: #1929
File: router/internal/circuit/manager.go:16-25
Timestamp: 2025-06-30T20:39:02.387Z
Learning: In the Cosmo router project, parameter validation for circuit breaker configuration is handled at the JSON schema level rather than through runtime validation methods on structs. The config.schema.json file contains comprehensive validation constraints for circuit breaker parameters.
</retrieved_learning>

<retrieved_learning>
Learnt from: endigma
PR: #2009
File: router/pkg/config/config.go:0-0
Timestamp: 2025-07-03T10:33:25.778Z
Learning: The CardinalityLimit field in the Metrics struct (router/pkg/config/config.go) is validated at the JSON schema level in config.schema.json with a minimum value constraint of 1, preventing zero or negative values without requiring runtime validation.
</retrieved_learning>

⏰ 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). (9)
  • GitHub Check: build-router
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_push_image
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: build_test
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (9)
router/core/executor.go (1)

84-84: Verify extension-fields precedence and mode scope

The new AllowAllErrorExtensionFields flag is correctly wired into resolve.ResolverOptions, but since the resolver logic lives in the external resolve package, please manually verify:

  • Precedence: how AllowAllErrorExtensionFields interacts with AllowedErrorExtensionFields at runtime.
  • Mode applicability: should “allow all” apply in both passthrough and wrapped modes, or be restricted to passthrough?
  • Tests: add or update end-to-end tests covering combinations of both flags in each propagation mode to ensure behavior matches expectations.
router/pkg/config/testdata/config_full.json (4)

750-750: Configuration change aligns with PR objective.

The mode change from "wrapped" to "pass-through" is consistent with the PR's goal of disabling error extension filtering in passthrough mode.


753-753: OmitExtensions set to true is appropriate for test data.

This setting ensures that the test validates the behavior when extensions are omitted, which is a valid test scenario.


756-756: New AllowAllExtensionFields configuration looks good.

The new boolean flag is properly configured and aligns with the feature implementation. Setting it to true in test data will help validate the new functionality.


758-759: AllowedExtensionFields updated for testing.

The field values have been updated from ["code"] to ["field1", "field2"] which appears to be more appropriate for testing the extension field filtering functionality.

router/pkg/config/fixtures/full.yaml (2)

317-317: Minor stylistic change - no functional impact.

The change from double quotes to single quotes for the Redis URL is purely stylistic and doesn't affect functionality.


448-459: Comprehensive subgraph error propagation configuration added.

The new configuration block provides all the necessary options for controlling error propagation behavior, including the new allow_all_extension_fields flag. The configuration structure is well-organized and follows YAML best practices.

router/pkg/config/config.go (2)

727-737: Environment variable tag refactoring and new field addition.

The environment variable tags have been simplified by removing the redundant SUBGRAPH_ERROR_PROPAGATION_ prefix from individual fields. The new AllowAllExtensionFields field is properly typed with a conservative default of false, which is appropriate for security.


1013-1013: Environment variable prefix properly scoped.

The addition of envPrefix:"SUBGRAPH_ERROR_PROPAGATION_" to the main struct ensures that environment variables are properly scoped, complementing the tag simplification in the nested struct.

@endigma endigma force-pushed the jesse/eng-7495-custom-extension-field-stripping branch from ecfc4dc to 668d5ac Compare July 9, 2025 10:11
@endigma endigma requested a review from SkArchon July 9, 2025 10:30
@endigma endigma force-pushed the jesse/eng-7495-custom-extension-field-stripping branch from 668d5ac to 9643c49 Compare July 9, 2025 11:21
@endigma endigma changed the title feat: disable error extension filtering in passthrough mode feat: option to allow all error extensions Jul 9, 2025
@endigma endigma force-pushed the jesse/eng-7495-custom-extension-field-stripping branch from c67a916 to 7eff7bf Compare July 9, 2025 13:00
@endigma endigma changed the title feat: option to allow all error extensions feat(router): option to allow all error extensions Jul 9, 2025
@endigma endigma force-pushed the jesse/eng-7495-custom-extension-field-stripping branch 2 times, most recently from 1a566c7 to 245f417 Compare July 10, 2025 09:23
Copy link
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

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

LGTM

@endigma endigma force-pushed the jesse/eng-7495-custom-extension-field-stripping branch from 245f417 to a7d904b Compare July 10, 2025 11:22
@endigma endigma force-pushed the jesse/eng-7495-custom-extension-field-stripping branch from 360baf3 to ca82696 Compare July 10, 2025 13:59
@endigma endigma merged commit 8fa9c45 into main Jul 10, 2025
37 of 39 checks passed
@endigma endigma deleted the jesse/eng-7495-custom-extension-field-stripping branch July 10, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants