Skip to content

Commit f403ecb

Browse files
Copilotjoshspicer
andcommitted
Make pull_request field optional in JobInfo validator and interface
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
1 parent 89ef419 commit f403ecb

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/platform/github/common/githubAPIValidators.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export const vJobInfo = (): IValidator<JobInfo> => vObj({
3737
actor: vRequired(vActor()),
3838
created_at: vRequired(vString()),
3939
updated_at: vRequired(vString()),
40-
pull_request: vRequired(vObj({
40+
pull_request: vObj({
4141
id: vRequired(vNumber()),
4242
number: vRequired(vNumber()),
43-
})),
43+
}),
4444
workflow_run: vObj({
4545
id: vRequired(vNumber()),
4646
}),

src/platform/github/common/githubService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface JobInfo {
4141
};
4242
created_at: string;
4343
updated_at: string;
44-
pull_request: {
44+
pull_request?: {
4545
id: number;
4646
number: number;
4747
};

src/platform/github/test/common/githubAPIValidators.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,26 @@ describe('GitHub API Validators', () => {
126126
const result = vJobInfo().validate(invalidJobInfo);
127127
expect(result.error).toBeDefined();
128128
});
129+
130+
it('should validate job info without pull_request field', () => {
131+
const validJobInfo = {
132+
job_id: 'job-123',
133+
session_id: 'session-456',
134+
problem_statement: 'Fix the bug',
135+
status: 'completed',
136+
actor: {
137+
id: 123,
138+
login: 'testuser'
139+
},
140+
created_at: '2023-01-01T00:00:00Z',
141+
updated_at: '2023-01-02T00:00:00Z'
142+
// No pull_request field - should still be valid
143+
};
144+
145+
const result = vJobInfo().validate(validJobInfo);
146+
expect(result.error).toBeUndefined();
147+
expect(result.content).toEqual(validJobInfo);
148+
});
129149
});
130150

131151
describe('vRemoteAgentJobResponse', () => {

0 commit comments

Comments
 (0)