-
Notifications
You must be signed in to change notification settings - Fork 13k
fix: improves how code access user-agent in the headers #37493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 37c1297 The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughA patch was released for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #37493 +/- ##
========================================
Coverage 68.96% 68.97%
========================================
Files 3357 3357
Lines 114251 114251
Branches 20536 20536
========================================
+ Hits 78795 78804 +9
+ Misses 33369 33354 -15
- Partials 2087 2093 +6
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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)
apps/meteor/ee/server/lib/deviceManagement/session.ts (1)
105-105: Consider optional chaining for consistency.While line 70 now uses optional chaining (
connection?.httpHeaders?.['user-agent']), this line still accesses the header directly. Although this occurs in a context where the connection should exist, adopting optional chaining here would improve consistency and defensive programming.Apply this diff for consistency:
- mailData.userAgent = connection.httpHeaders['user-agent'] || ''; + mailData.userAgent = connection?.httpHeaders?.['user-agent'] ?? '';
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.changeset/healthy-rabbits-sip.md(1 hunks)apps/meteor/ee/server/lib/deviceManagement/session.ts(1 hunks)
🔇 Additional comments (3)
.changeset/healthy-rabbits-sip.md (1)
1-5: LGTM! Changeset properly documents the fix.The changeset correctly documents a patch-level fix for extracting user-agent from DDP connection headers.
apps/meteor/ee/server/lib/deviceManagement/session.ts (2)
70-71: Excellent fix! Correctly addresses the DDP header structure issue.The change properly handles the fact that DDP connections provide
httpHeadersas a plain object rather than a Headers instance. Using optional chaining with a nullish coalescing fallback ensures safe access and provides a valid string to the parser.
70-71: I need to perform more targeted searches in the enterprise edition directory to verify test coverage:Now let me search the codebase directly for test coverage:
Based on the initial script output showing no test files found for device management session, let me complete the verification by searching for test patterns more directly:
Based on the script execution results, I can now provide the verification:
The review comment is accurate and well-founded.
The shell script executed explicitly searched for test files related to device management session functionality using the patterns
"deviceManagement.*session"and"listenSessionLogin"and returned zero results. The only matches found were unrelated HTTP request tests inmetrics.spec.tsthat set user-agent headers, not device management tests.This confirms that:
- No unit or spec tests exist for
apps/meteor/ee/server/lib/deviceManagement/session.ts- The header extraction fix at lines 70-71 (extracting
user-agentfromconnection?.httpHeaders?.['user-agent']) lacks test coverage- The PR does not include tests for scenarios like missing user-agent headers or various connection object structures
Test Coverage Status:
- ✗ Tests for correct extraction when user-agent is present: Not included
- ✗ Tests for safe handling when user-agent is missing: Not included
- ✗ Tests for various connection object structures: Not included
Verify the fix is covered by tests that validate:
- Correct extraction when user-agent is present
- Safe handling when user-agent is missing
- Behavior with various connection object structures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
/patch |
|
Pull request #37540 added to Project: "Patch 7.12.2" |
|
/backport 7.11.2 |
|
Pull request #37541 added to Project: "Patch 7.11.2" |

Proposed changes (including videos or screenshots)
This PR aims at fixing an error when trying to extract
user-agentfrom DDP headers.Issue(s)
SUP-922
Steps to test or reproduce
Further comments
This issue is related to another task; CORE-1497. We will be improving how we handle headers and header props extracted from DDP header object as well as implementing tests to validate these props are properly handled.
Summary by CodeRabbit