Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions services/app-builder/src/api-schemas.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from 'vitest';
import { MigrateToGithubRequestSchema } from './api-schemas';

describe('MigrateToGithubRequestSchema', () => {
const request = {
githubRepo: 'kilocode/example',
userId: 'user_2abc123',
};

it('accepts non-empty text user IDs', () => {
expect(MigrateToGithubRequestSchema.parse(request)).toEqual(request);
});

it('rejects empty user IDs', () => {
expect(() => MigrateToGithubRequestSchema.parse({ ...request, userId: '' })).toThrow();
});

it('keeps organization IDs UUID-only', () => {
expect(() =>
MigrateToGithubRequestSchema.parse({ ...request, orgId: 'org_2abc123' })
).toThrow();
expect(
MigrateToGithubRequestSchema.parse({
...request,
orgId: '123e4567-e89b-42d3-a456-426614174000',
})
).toEqual({
...request,
orgId: '123e4567-e89b-42d3-a456-426614174000',
});
});
});
2 changes: 1 addition & 1 deletion services/app-builder/src/api-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export type DeleteErrorResponse = z.infer<typeof DeleteErrorResponseSchema>;

export const MigrateToGithubRequestSchema = z.object({
githubRepo: z.string().regex(/^[^/]+\/[^/]+$/, 'Must be in "owner/repo" format'),
userId: z.string().uuid(),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Users with non-UUID Kilo User IDs fail due to the parsing here

userId: z.string().min(1),
orgId: z.string().uuid().optional(),
});

Expand Down