Repository navigation
fix(api-callers): resolve C# request URLs built in variables - #124
Merged
Merged
Conversation
find_api_callers did not find a C# client that builds the URL on an
earlier line and sends it with HttpRequestMessage, for example:
string url = id.HasValue ? $"api/v2/a/run/instance/{id}" : $"api/v2/a/run/{eid}";
new HttpRequestMessage(HttpMethod.Post, url)
C# files now also recognize HttpRequestMessage with HttpMethod.X or
new HttpMethod("X"), any *Client.<Verb>*Async call (generic type
arguments allowed), interpolated strings, "path/" + id concatenation,
and a URL variable resolved from its nearest assignment. Each URL
literal in that assignment is one call.
The fetch rule also matched text between `httpRequest` and a later
parenthesis, so httpRequest.Headers.Accept.Add(new X("text/event-stream"))
became a GET call. It now matches the call itself only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le-callers # Conflicts: # REQUIREMENTS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
find_api_callersdid not find this C# client call (a real client library):The C# rule only knew
httpClient|_httpClient|client.<Verb>Async("literal"). Also, thefetchrule allowed any text betweenhttpRequestand a later(, sohttpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/event-stream"))became a falseGET /text/event-streamcall.Fix
app/services/chunking/csharp_client_calls.py(used for C# files only):new HttpRequestMessage(HttpMethod.Post, ...)andnew HttpRequestMessage(new HttpMethod("PATCH"), ...)<anything>Client.<Verb>*Async(...), with an optional generic type argument$"..."),"path/" + id(becomespath/{id}), or a variable. A variable is resolved from its nearest assignment in the 40 lines above; each URL literal in that statement is one call (both branches of a conditional)._FETCH_CALLnow matches only the call itself (fetch(,requestJson<T>().Tests
tests/test_csharp_client_calls.py: the conditional URL variable (both routes, matched againstapi/v{version}/assistants/run/{eid}), interpolated literals with a custom client name and generic arguments, concatenation, variables without a URL are ignored, and other languages are not affected. The existingtests/test_api_client_calls.pypasses.🤖 Generated with Claude Code