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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"axios": "^1.7.0",
"form-data": "^4.0.5",
"md-to-adf": "^0.5.0",
"zod": "^3.22.4"
"zod": "^4.4.2"
},
"devDependencies": {
"@types/node": "^25.3.3",
Expand Down
2 changes: 1 addition & 1 deletion src/types/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const CreateIssueInputSchema = z.object({
labels: z.array(z.string()).optional().describe('Issue labels'),
components: z.array(z.string()).optional().describe('Component names'),
customFields: z
.record(z.any())
.record(z.string(), z.any())
.optional()
.describe(
'Additional Jira field mappings, e.g. { "customfield_12345": value }. Use for required custom fields.'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function validateInput<T>(schema: ZodSchema<T>, input: unknown): T {
return schema.parse(input);
} catch (error) {
if (error instanceof z.ZodError) {
const errorMessages = error.errors.map((err) => `${err.path.join('.')}: ${err.message}`);
const errorMessages = error.issues.map((err) => `${err.path.join('.')}: ${err.message}`);
throw new Error(`${ERROR_MESSAGES.VALIDATION_ERROR}\n${errorMessages.join('\n')}`);
}
throw error;
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/tools/create-issue-link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createIssueLinkTool,
} from '../../../src/tools/create-issue-link.js';
import { validateInput } from '../../../src/utils/validators.js';
import { CreateIssueLinkInputSchema } from '../../../src/types/tools.js';
import { createIssueLink } from '../../../src/utils/api-helpers.js';
import { formatSuccessResponse } from '../../../src/utils/formatters.js';
import { handleError } from '../../../src/utils/error-handler.js';
Expand Down Expand Up @@ -194,14 +195,7 @@ describe('create-issue-link tool', () => {

await handleCreateIssueLink(input);

expect(mockedValidateInput).toHaveBeenCalledWith(
expect.objectContaining({
_def: expect.objectContaining({
typeName: 'ZodObject',
}),
}),
input
);
expect(mockedValidateInput).toHaveBeenCalledWith(CreateIssueLinkInputSchema, input);
});

it('should handle validation errors for missing fromIssue', async () => {
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/tools/create-issue.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { handleCreateIssue, createIssueTool } from '../../../src/tools/create-issue.js';
import { validateInput } from '../../../src/utils/validators.js';
import { CreateIssueInputSchema } from '../../../src/types/tools.js';
import { createIssue } from '../../../src/utils/api-helpers.js';
import { formatIssueResponse } from '../../../src/utils/formatters.js';
import { handleError } from '../../../src/utils/error-handler.js';
Expand Down Expand Up @@ -219,14 +220,7 @@ describe('create-issue tool', () => {

await handleCreateIssue(input);

expect(mockedValidateInput).toHaveBeenCalledWith(
expect.objectContaining({
_def: expect.objectContaining({
typeName: 'ZodObject',
}),
}),
input
);
expect(mockedValidateInput).toHaveBeenCalledWith(CreateIssueInputSchema, input);
});

it('should handle validation errors for missing required fields', async () => {
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/tools/get-issue.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { handleGetIssue, getIssueTool } from '../../../src/tools/get-issue.js';
import { validateInput, extractIssueKey } from '../../../src/utils/validators.js';
import { GetIssueInputSchema } from '../../../src/types/tools.js';
import { getIssue } from '../../../src/utils/api-helpers.js';
import { formatIssueResponse } from '../../../src/utils/formatters.js';
import { handleError } from '../../../src/utils/error-handler.js';
Expand Down Expand Up @@ -201,14 +202,7 @@ describe('get-issue tool', () => {

await handleGetIssue(input);

expect(mockedValidateInput).toHaveBeenCalledWith(
expect.objectContaining({
_def: expect.objectContaining({
typeName: 'ZodObject',
}),
}),
input
);
expect(mockedValidateInput).toHaveBeenCalledWith(GetIssueInputSchema, input);
});

it('should handle validation errors', async () => {
Expand Down
10 changes: 2 additions & 8 deletions tests/unit/tools/search-issues.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { handleSearchIssues, searchIssuesTool } from '../../../src/tools/search-issues.js';
import { validateInput } from '../../../src/utils/validators.js';
import { SearchIssuesInputSchema } from '../../../src/types/tools.js';
import { searchIssues } from '../../../src/utils/api-helpers.js';
import { formatSearchResultsResponse } from '../../../src/utils/formatters.js';
import { handleError } from '../../../src/utils/error-handler.js';
Expand Down Expand Up @@ -207,14 +208,7 @@ describe('search-issues tool', () => {

await handleSearchIssues(input);

expect(mockedValidateInput).toHaveBeenCalledWith(
expect.objectContaining({
_def: expect.objectContaining({
typeName: 'ZodObject',
}),
}),
input
);
expect(mockedValidateInput).toHaveBeenCalledWith(SearchIssuesInputSchema, input);
});

it('should handle validation errors for missing JQL', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/validators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ describe('validators', () => {

it('should handle missing required fields', () => {
const input = { age: 30 };
expect(() => validateInput(testSchema, input)).toThrow('name: Required');
expect(() => validateInput(testSchema, input)).toThrow('email: Required');
expect(() => validateInput(testSchema, input)).toThrow('name: Invalid input');
expect(() => validateInput(testSchema, input)).toThrow('email: Invalid input');
});

it('should rethrow non-zod errors', () => {
Expand Down
Loading