Skip to content

Add GraphQL query complexity/depth limiting and missing unit tests for pkg/projects and pkg/probe #5562

Description

@VarshaUN

Hi maintainers,

I've been getting set up to contribute and while going through chaoscenter/graphql/server I noticed two related gaps. Wanted to open this as a discussion before writing any code, per the CONTRIBUTING guide.

A few core packages have no test files at all
While checking coverage, these have zero _test.go files:

pkg/projects (project_handler.go) — handles project creation/init, no tests
pkg/probe (handler/handler.go) — has a ready-made mock in pkg/probe/model/mocks/service.go that nothing currently uses
pkg/image_registry, pkg/gitops, pkg/grpc , same situation

pkg/projects and pkg/probe seemed like the most self-contained ones to start with since they already depend on the mongodb.MongoOperator interface, which is mockable, and pkg/probe already has the mock scaffolding sitting there unused.

Proposed scope

If this sounds reasonable, I'd like to take on:

Adding a complexity limit to the gqlgen handler in server.go (open to whatever threshold makes sense, can also look at depth limiting if preferred)
Writing unit tests for pkg/projects/project_handler.go and pkg/probe/handler/handler.go using the existing mocks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions