Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add ctx propagation to raw api request#570

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SamMorrowDrums merged 1 commit intomainfromkerobbi/propagate-context
Jun 23, 2025

Conversation

kerobbi
Copy link
Contributor

UpdatenewRequest to accept acontext.Context param and attach it to the generatedhttp.Request usingwithContext.

This change ensures that trace contexts are correctly propagated, supporting distributed tracing in the remote MCP server.

@CopilotCopilotAI review requested due to automatic review settingsJune 23, 2025 08:42
@kerobbikerobbi requested a review froma team as acode ownerJune 23, 2025 08:42
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds context propagation to the low-levelnewRequest helper, ensuring that trace and cancellation contexts flow through HTTP calls in the raw API client.

  • ExtendednewRequest to accept acontext.Context and attach it viaWithContext
  • UpdatedGetRawContent to pass the incomingctx intonewRequest
  • Adjusted error handling innewRequest to return early on failure before setting context
Comments suppressed due to low confidence (3)

pkg/raw/raw.go:65

  • Add or update unit tests to verify that the provided context is actually attached to the outgoinghttp.Request and that cancellations/timeouts are honored.
func (c *Client) GetRawContent(ctx context.Context, owner, repo, path string, opts *RawContentOpts) (*http.Response, error) {

pkg/raw/raw.go:28

  • Make sure to import the "context" package at the top of this file, otherwisecontext.Context will be undefined.
func (c *Client) newRequest(ctx context.Context, method string, urlStr string, body interface{}, opts ...gogithub.RequestOption) (*http.Request, error) {

pkg/raw/raw.go:67

  • Review other methods in this file (or in downstream code) that callnewRequest to ensure they’ve been updated to passctx as the first argument, preventing build failures and ensuring consistent context propagation.
req, err := c.newRequest(ctx, "GET", url, nil)

Copy link
Collaborator

@SamMorrowDrumsSamMorrowDrums left a comment

Choose a reason for hiding this comment

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

Just to validate, does this work if you try it locally? I assume so, but an alternative is to take the current request context and then extend it and add it back to the request.

@kerobbi
Copy link
ContributorAuthor

Just to validate, does this work if you try it locally? I assume so, but an alternative is to take the current request context and then extend it and add it back to the request.

I did test this locally and confirmed that ctx propagation is working as expected, trace info and parent-child spans are all showing up correctly.

I'm a bit confused about the suggested alternative. Since we are creating a new outbound request here (not working with an incoming HTTP request), I don't think there's an existing req ctx to extend? Let me know if I'm missing something.

@SamMorrowDrumsSamMorrowDrums merged commit2711384 intomainJun 23, 2025
16 checks passed
@SamMorrowDrumsSamMorrowDrums deleted the kerobbi/propagate-context branchJune 23, 2025 12:55
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@SamMorrowDrumsSamMorrowDrumsSamMorrowDrums approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@kerobbi@SamMorrowDrums

[8]ページ先頭

©2009-2025 Movatter.jp