Type the upload payload object

This commit is contained in:
Michael B. Gale
2026-02-11 23:40:55 +00:00
parent db9346285d
commit cbb92e7ff6
3 changed files with 29 additions and 4 deletions
+10 -1
View File
@@ -12,6 +12,7 @@ import * as api from "./api-client";
import { getRunnerLogger, Logger } from "./logging";
import { setupTests } from "./testing-utils";
import * as uploadLib from "./upload-lib";
import { UploadPayload } from "./upload-lib/types";
import { GitHubVariant, initializeEnvironment, withTmpDir } from "./util";
setupTests(test);
@@ -909,7 +910,15 @@ function createMockSarif(id?: string, tool?: string) {
function uploadPayloadFixtures(analysis: analyses.AnalysisConfig) {
const mockData = {
payload: { sarif: "base64data", commit_sha: "abc123" },
payload: {
commit_oid: "abc123",
ref: "ref",
sarif: "base64data",
workflow_run_id: 1,
workflow_run_attempt: 1,
checkout_uri: "uri",
tool_names: ["codeql"],
} satisfies UploadPayload,
owner: "test-owner",
repo: "test-repo",
response: {
+4 -3
View File
@@ -21,6 +21,7 @@ import * as gitUtils from "./git-utils";
import { initCodeQL } from "./init";
import { Logger } from "./logging";
import { getRepositoryNwo, RepositoryNwo } from "./repository";
import { UploadPayload } from "./upload-lib/types";
import * as util from "./util";
import {
ConfigurationError,
@@ -326,7 +327,7 @@ function getAutomationID(
* This is exported for testing purposes only.
*/
export async function uploadPayload(
payload: any,
payload: UploadPayload,
repositoryNwo: RepositoryNwo,
logger: Logger,
analysis: analyses.AnalysisConfig,
@@ -618,8 +619,8 @@ export function buildPayload(
environment: string | undefined,
toolNames: string[],
mergeBaseCommitOid: string | undefined,
) {
const payloadObj = {
): UploadPayload {
const payloadObj: UploadPayload = {
commit_oid: commitOid,
ref,
analysis_key: analysisKey,
+15
View File
@@ -0,0 +1,15 @@
export interface UploadPayload {
commit_oid: string;
ref: string;
analysis_key?: string;
analysis_name?: string;
sarif: string;
workflow_run_id: number;
workflow_run_attempt: number;
checkout_uri: string;
environment?: string;
started_at?: string;
tool_names: string[];
base_ref?: string;
base_sha?: string;
}