-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Overview
API client methods don't validate that required parameters are non-empty before making API calls. This leads to confusing API errors instead of clear validation messages.
Affected Methods
Workspaces API (internal/api/workspaces.go)
GetWorkspace(ctx, workspaceSlug)- workspaceSlug could be emptyListWorkspaceMembers(ctx, workspaceSlug, opts)- workspaceSlug could be empty
Projects API (internal/api/projects.go)
ListProjects(ctx, workspaceSlug, opts)GetProject(ctx, workspaceSlug, projectKey)CreateProject(ctx, workspaceSlug, opts)UpdateProject(ctx, workspaceSlug, projectKey, opts)DeleteProject(ctx, workspaceSlug, projectKey)
Branches API (internal/api/branches.go)
ListBranches(ctx, workspace, repoSlug, opts)GetBranch(ctx, workspace, repoSlug, branchName)CreateBranch(ctx, workspace, repoSlug, opts)DeleteBranch(ctx, workspace, repoSlug, branchName)
Also in existing code (internal/api/repositories.go)
- Same pattern exists in repository methods
Proposed Solution
Add validation at the start of each method:
func (c *Client) GetProject(ctx context.Context, workspaceSlug, projectKey string) (*ProjectFull, error) {
if workspaceSlug == "" {
return nil, fmt.Errorf("workspaceSlug is required")
}
if projectKey == "" {
return nil, fmt.Errorf("projectKey is required")
}
// ... rest of method
}Benefits
- Clear error messages for invalid input
- Fail fast before making network request
- Easier debugging
Acceptance Criteria
- Add validation for all API methods with required parameters
- Add test cases for validation errors
- Consistent error message format
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request