Skip to content

Comments

feat: add custom User-Agent header for AWS SDK requests#13279

Merged
czubocha merged 2 commits intomainfrom
sc-3764
Jan 20, 2026
Merged

feat: add custom User-Agent header for AWS SDK requests#13279
czubocha merged 2 commits intomainfrom
sc-3764

Conversation

@czubocha
Copy link
Contributor

@czubocha czubocha commented Jan 20, 2026

Summary

  • Adds serverless-framework/<version> to the User-Agent header for all AWS SDK v3 API requests
  • Implemented in addProxyToAwsClient() in @serverless/util which wraps all AWS clients
  • Uses __SF_CORE_VERSION__ build-time constant for the version

Example User-Agent:

aws-sdk-js/3.966.0 ua/2.1 os/darwin#25.1.0 lang/js md/nodejs#24.13.0 api/cloudformation#3.966.0 m/E,T,s,r serverless-framework/4.31.0

Test plan

  • Verified with NODE_DEBUG=https that serverless-framework/4.31.0 appears in all AWS API requests
  • Tested with both SLS_AWS_SDK=3 and default SDK paths
  • Verified version changes after rebuilding with different version in package.json
  • Lint passes

How to test

# Build the bundle
cd packages/sf-core && npm run build

# Create a test service and run with NODE_DEBUG=https to see HTTP headers
NODE_DEBUG=https serverless info 2>&1 | grep -i "serverless-framework"

Expected output should include:

'x-amz-user-agent': 'aws-sdk-js/3.966.0 serverless-framework/4.31.0',
'user-agent': 'aws-sdk-js/3.966.0 ua/2.1 os/darwin#25.1.0 lang/js md/nodejs#24.13.0 api/sts#3.966.0 m/E,s,r serverless-framework/4.31.0',

Related

Closes #13245

Summary by CodeRabbit

  • Chores
    • Improved request identification for Serverless Framework operations when using proxy configurations, enhancing request tracking and diagnostics.
    • Updated contributor/automation allowlist in CI checks to include an additional bot entry.

✏️ Tip: You can customize this high-level summary in your review settings.

@czubocha czubocha requested a review from eahefnawy January 20, 2026 12:55
@Mmarzex
Copy link
Contributor

Mmarzex commented Jan 20, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Injects a build-time custom user agent for Serverless Framework into AWS SDK v3 client configuration at runtime when proxy code paths are used. Applies a conditional SF_CORE_VERSION-based identifier to the client after creation; proxy and NO_PROXY logic remain unchanged.

Changes

Cohort / File(s) Summary
User-Agent Injection for AWS SDK v3
packages/util/src/proxy/aws.js
Adds build-time __SF_CORE_VERSION__-based customUserAgent and assigns it to the AWS SDK v3 client configuration at runtime when proxy handling is used (no changes to proxy decision logic).
CI allowlist update
.github/workflows/check-cla.yml
Adds an entry coderabbitai[bot] to the allowlist in the CLA check workflow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰
I hopped through code at break of day,
A tiny tag to show the way,
"serverless-framework" I proudly say,
Tracing requests as they leap and play,
A carrot cheer for builds today! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR contains a minor out-of-scope change: updating .github/workflows/check-cla.yml to add coderabbitai[bot] to the allowlist, which is unrelated to the User-Agent feature. Remove the coderabbitai[bot] allowlist entry from check-cla.yml or document its necessity, as it falls outside the scope of issue #13245.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the primary change: adding a custom User-Agent header for AWS SDK requests, which matches the implementation in packages/util/src/proxy/aws.js.
Linked Issues check ✅ Passed The PR implementation successfully meets issue #13245's requirement by adding 'serverless-framework/' to User-Agent headers for AWS SDK v3 requests using build-time injected SF_CORE_VERSION.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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.

Copy link
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

🤖 Fix all issues with AI agents
In `@packages/util/src/proxy/aws.js`:
- Around line 177-183: In addProxyToAwsClient, don’t overwrite
client.config.customUserAgent; instead merge/append the Serverless token
(customUserAgent) into the existing client.config.customUserAgent while avoiding
duplicates: detect whether client.config.customUserAgent is a string or array,
normalize to an array, push the customUserAgent only if not already present, and
set client.config.customUserAgent back to the normalized form expected by the
AWS SDK; reference the addProxyToAwsClient function, the customUserAgent
variable, and client.config.customUserAgent when making the change.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #13280

coderabbitai bot added a commit that referenced this pull request Jan 20, 2026
Docstrings generation was requested by @czubocha.

* #13279 (comment)

The following files were modified:

* `packages/util/src/proxy/aws.js`
@czubocha
Copy link
Contributor Author

@coderabbitai help

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue 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 evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @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 to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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.
  • You can also validate your configuration using the online YAML validator.
  • 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

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@czubocha czubocha merged commit 4496dae into main Jan 20, 2026
12 checks passed
@czubocha czubocha deleted the sc-3764 branch January 20, 2026 17:25
@github-actions github-actions bot locked and limited conversation to collaborators Jan 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use serverless-framework User-Agent for API requests

3 participants