Skip to content

feat(middleware): add request id to response header in RequestIDMiddleware - #43

Merged
milaguyenlam merged 4 commits into
masterfrom
add-request-id-to-response-middleware
Jan 30, 2026
Merged

milaguyenlam merged 4 commits into
masterfrom
add-request-id-to-response-middleware

Conversation

@milaguyenlam

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @milaguyenlam, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new feature to the RequestIDMiddleware that enhances request traceability. Previously, the middleware would generate or retrieve a request ID and store it in the request context. With this change, the same request ID is now also added to the X-Request-ID HTTP response header, making it easier to track requests across distributed systems and for client-side debugging.

Highlights

  • Response Header Inclusion: The RequestIDMiddleware now explicitly sets the X-Request-ID header in the HTTP response, ensuring that the unique request identifier is returned to the client.
  • Documentation Update: The inline documentation for RequestIDMiddleware has been updated to accurately reflect its new behavior of saving the request ID to both the request context and the response header.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@codecov-commenter

codecov-commenter commented Jan 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.32%. Comparing base (f0cc04f) to head (14c7c02).

Files with missing lines Patch % Lines
http/middleware.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #43      +/-   ##
==========================================
- Coverage   66.55%   66.32%   -0.23%     
==========================================
  Files          12       12              
  Lines         586      588       +2     
==========================================
  Hits          390      390              
- Misses        185      187       +2     
  Partials       11       11              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request aims to add the request ID to the response headers in the RequestIDMiddleware. The change correctly updates the function's documentation and adds the necessary code to set the header. However, I've identified a logical flaw where the response header is not set if the request ID already exists in the context, causing the feature to be incomplete. My review includes a comment detailing this issue.

Comment thread http/middleware.go
@milaguyenlam
milaguyenlam force-pushed the add-request-id-to-response-middleware branch from 3788b33 to d2328bc Compare January 23, 2026 12:02
TomasKocman
TomasKocman previously approved these changes Jan 30, 2026
@milaguyenlam
milaguyenlam merged commit 9280e55 into master Jan 30, 2026
3 checks passed
@milaguyenlam
milaguyenlam deleted the add-request-id-to-response-middleware branch January 30, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants