Skip to content

fix(router): allow from_file header to be propagated#2979

Merged
Noroth merged 1 commit into
mainfrom
ludwig/fix-file-header-validation
Jun 18, 2026
Merged

fix(router): allow from_file header to be propagated#2979
Noroth merged 1 commit into
mainfrom
ludwig/fix-file-header-validation

Conversation

@Noroth

@Noroth Noroth commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

File headers were missing in the validation for the factory resolver. This PR adds this and also adds missing tests

Summary by CodeRabbit

  • New Features

    • Request headers can now be set using values sourced directly from external files, providing greater flexibility in configuring headers across your routing setup.
  • Tests

    • Added integration and unit tests to verify file-based header sourcing functionality works correctly.
  • Bug Fixes

    • Enhanced validation for header set rules to ensure all required configuration fields are present and properly configured before processing.

Checklist

Open Source AI Manifesto

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

@Noroth Noroth requested a review from a team as a code owner June 18, 2026 08:48
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds FromFile to the HeaderRuleOperationSet invalid-rule guard in PropagatedHeaders, a unit test for Set+FromFile in TestPropagatedHeaders, and an integration test TestHeaderSetFromFile that writes a header value to a temp file and verifies the router returns that value for both global and subgraph-scoped request header rules.

Changes

FromFile header set validation and test coverage

Layer / File(s) Summary
PropagatedHeaders FromFile validation fix and unit test
router/core/header_rule_engine.go, router/core/header_rule_engine_test.go
Extends the HeaderRuleOperationSet invalid-rule condition to also reject rules where FromFile is absent alongside Value, ValueFrom, and Expression. Adds a TestPropagatedHeaders subtest confirming Set+FromFile rules yield the header name and no compiled regexps.
Integration test for file-sourced header set rules
router-tests/protocol/header_set_test.go
Adds os/path/filepath imports and TestHeaderSetFromFile, which writes a header value to a temp file, configures RequestHeaderRule.FromFile, and asserts the router returns the file-derived value for both All.Request (global) and Subgraphs[...].Request (subgraph-specific) rules.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • wundergraph/cosmo#2908: Implements the FromFile header source feature in header_rule_engine.go that this PR's validation fix and tests directly build upon.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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
Title check ✅ Passed The pull request title accurately summarizes the main change: adding support for propagating file-based headers through validation in the router's header rule engine.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Router image scan passed

✅ No security vulnerabilities found in image:

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

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.42%. Comparing base (7532f9a) to head (57560cc).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2979      +/-   ##
==========================================
+ Coverage   65.34%   66.42%   +1.08%     
==========================================
  Files         335      258      -77     
  Lines       48194    27557   -20637     
  Branches     5371        0    -5371     
==========================================
- Hits        31491    18306   -13185     
+ Misses      16677     7792    -8885     
- Partials       26     1459    +1433     
Files with missing lines Coverage Δ
router/core/header_rule_engine.go 88.21% <100.00%> (ø)

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

@Noroth Noroth merged commit 60b55da into main Jun 18, 2026
38 checks passed
@Noroth Noroth deleted the ludwig/fix-file-header-validation branch June 18, 2026 10:53
@Noroth Noroth mentioned this pull request Jun 18, 2026
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.

2 participants