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 empty
ListWorkspaceMembers(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
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 emptyProjects 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)Proposed Solution
Add validation at the start of each method:
Benefits
Acceptance Criteria