github: avoid unnecessary allocations during request validation. by dmitrivMS · Pull Request #343186 · microsoft/vscode · GitHub
Skip to content

github: avoid unnecessary allocations during request validation. - #343186

Open
Dmitriy Vasyura (dmitrivMS) wants to merge 1 commit into
mainfrom
dev/dmitriv/github-parse
Open

Dmitriy Vasyura (dmitrivMS) wants to merge 1 commit into
mainfrom
dev/dmitriv/github-parse

Conversation

@dmitrivMS

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 10:02
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the network Network related issues label Oct 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

This PR updates GitHub client schema parsing and request handling to reduce allocations and prevent untrusted request options/payload fields from overriding internal controls.

Changes:

  • Updated schema parsers to reuse unchanged arrays/objects, and added parse.copyObject for explicit field filtering.
  • Hardened raw content request handling by whitelisting transport options (preventing overrides of URL/limits/timeouts).
  • Adjusted request plumbing to separate request bodies from request metadata (e.g., for IPC/validation).
File Description
src/​vs/​platform/​github/​common/​client/​schema.ts Reworks collection/object parsers for reuse and adds copyObject/copy helper.
src/​vs/​platform/​github/​common/​client/​request.ts Separates request body from metadata when issuing requests.
src/​vs/​platform/​github/​common/​client/​localApiRequestProvider.ts Whitelists allowed raw download options to prevent unsafe overrides.
src/​vs/​platform/​github/​common/​missionControl/​missionControlClient.ts Uses copying parsers to retain only documented API error diagnostics.
src/​vs/​platform/​github/​test/​common/​schema.test.ts Adds extensive tests for reuse/copy semantics, proto safety, and mutation guarantees.
src/​vs/​platform/​github/​test/​common/​localApiRequestProvider.test.ts Tests that raw request options can’t override pinned URL/limits/timeouts.
src/​vs/​platform/​github/​test/​common/​githubChannel.test.ts IPC-level test for raw wire options override protection.
src/​vs/​platform/​github/​test/​node/​missionControlClient.test.ts Extends error-shaping test coverage for documented diagnostics.
src/​vs/​platform/​github/​README.md Documents updated schema semantics and safety/validation behavior.

Review effort: Lite

Comment on lines +302 to +311
/** Copies own fields, including non-enumerable values, into a plain object. */
function copyRecord(record: Record<string, unknown>): Record<string, unknown> {
const result = { ...record };
for (const key of Object.getOwnPropertyNames(record)) {
if (!Object.hasOwn(result, key)) {
defineEntry(result, key, record[key]);
}
}
return result;
}
Comment on lines +44 to +47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

network Network related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants