Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Add validation for untrusted GitHub API responses#1987

Draft
Copilot wants to merge 3 commits into
joshspicer/apifrom
copilot/update-github-api-validation
Draft

Add validation for untrusted GitHub API responses#1987
Copilot wants to merge 3 commits into
joshspicer/apifrom
copilot/update-github-api-validation

Conversation

Copilot AI commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

GitHub API responses are untrusted external data but were being used directly without validation, creating type safety and security risks.

Changes

  • Added validators (githubAPIValidators.ts) for 11 API response types: SessionInfo, PullRequestFile, JobInfo, IOctoKitUser, CustomAgentListItem, and response wrappers
  • Applied validation at consumption points in githubAPI.ts and githubService.ts (9 functions total)
  • Added error logging when validation fails, returning safe defaults instead of using malformed data

Example

Before:

const result = await makeGitHubAPIRequest(...);
return result || [];  // No validation, trusts external data

After:

const result = await makeGitHubAPIRequest(...);
if (!result) return [];

const validationResult = vArray(vPullRequestFile).validate(result);
if (validationResult.error) {
  this._logService.error(`Validation failed: ${validationResult.error.message}`);
  return [];
}
return validationResult.content;  // Type-safe, validated data

The validator library (similar to Zod) ensures external API data matches expected TypeScript types before use.

Original prompt

I've made a change to accurately reflect that the response from makeGitHubAPIRequest is untrusted.

Use #file:validator.ts (it's like zod)

The user has attached the following file paths as relevant context:

  • src/platform/configuration/common/validator.ts
  • src/platform/github/common/githubAPI.ts

TITLE: Updating GitHub API response validation logic

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 13, 2025 20:14
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
Copilot AI changed the title [WIP] Update GitHub API response validation logic Add validation for untrusted GitHub API responses Nov 13, 2025
Copilot AI requested a review from joshspicer November 13, 2025 20:25
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.

2 participants