Skip to content

Commit a483187

Browse files
fix: add parameter validation before authentication
Tests were expecting parameter validation to happen before authentication errors. This ensures that validation errors are thrown before attempting to create the GraphQL client. Changes: - Add parameter validation to all exported functions - Validate org, repo, and other required parameters before calling getGraphqlClient() - Ensures proper error messages for missing parameters Fixes test: "index exports - validates parameter requirements" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2337885 commit a483187

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,47 @@ function getGraphqlClient() {
4848
}
4949

5050
export async function upcomingEvents(org, repo) {
51+
// Validate parameters before creating auth
52+
if (!org || !repo) {
53+
throw new Error('Missing required parameters: org and repo are required')
54+
}
5155
return listUpcomingEvents(getGraphqlClient(), org, repo)
5256
}
5357

5458
export async function pastEvents(org, repo) {
59+
// Validate parameters before creating auth
60+
if (!org || !repo) {
61+
throw new Error('Missing required parameters: org and repo are required')
62+
}
5563
return listPastEvents(getGraphqlClient(), org, repo)
5664
}
5765

5866
export async function event(org, repo, number) {
67+
// Validate parameters before creating auth
68+
if (!org || !repo || !number) {
69+
throw new Error(
70+
'Missing required parameters: org, repo, and number are required'
71+
)
72+
}
5973
return getEvent(getGraphqlClient(), org, repo, number)
6074
}
6175

6276
export async function getTeam(org, teamSlug) {
77+
// Validate parameters before creating auth
78+
if (!org || !teamSlug) {
79+
throw new Error(
80+
'Missing required parameters: org and teamSlug are required'
81+
)
82+
}
6383
return getTeamById(getGraphqlClient(), org, teamSlug)
6484
}
6585

6686
export async function getFile(org, repo, filePath, options) {
87+
// Validate parameters before creating auth
88+
if (!org || !repo || !filePath) {
89+
throw new Error(
90+
'Missing required parameters: org, repo, and filePath are required'
91+
)
92+
}
6793
return getFileContent(getGraphqlClient(), org, repo, filePath, options)
6894
}

0 commit comments

Comments
 (0)