Skip to content

test: add fuzz tests for subscriber GraphQL data marshaling #5532

Description

@wingwogus

What happened:

chaoscenter/subscriber/pkg/graphql/operations.go has MarshalGQLData, which converts arbitrary event data into a GraphQL-compatible quoted payload. This function handles escaped quotes, backslashes, control bytes, invalid UTF-8, and large string inputs, but it does not currently have focused fuzz coverage.

While testing edge cases, inputs such as \x7f, null bytes, raw newlines, backslashes, and invalid UTF-8 are useful for validating that MarshalGQLData always returns a safely quoted payload or returns an expected marshal error.

What you expected to happen:

MarshalGQLData should have a dedicated Go fuzz test that follows the existing Litmus fuzz test patterns:

  • seed representative string inputs
  • fuzz the function with arbitrary generated input
  • verify JSON-marshalable payloads do not return unexpected errors
  • verify returned payloads are quoted and unquotable
  • verify unsupported values such as functions, NaN, and Inf return marshal errors

Where can this issue be corrected? (optional)

chaoscenter/subscriber/pkg/graphql/operations_fuzz_test.go

Target function:

chaoscenter/subscriber/pkg/graphql/operations.go::MarshalGQLData

How to reproduce it (as minimally and precisely as possible):

Run the focused fuzz target after adding the fuzz test:

cd chaoscenter/subscriber
go test ./pkg/graphql -run=^$ -fuzz=FuzzMarshalGQLData -fuzztime=30s

Useful seed inputs include:

""
"plain-text"
`quotes: "value"`
`backslash: \`
"line one\nline two"
"null-byte:\x00"
"control-bytes:\x01\x02\x03"
"delete-control:\x7f"
"invalid-utf8:\xff\xfe\xfd"

Anything else we need to know?:

There are existing fuzz test examples in the repository that can be used as style references:

  • chaoscenter/graphql/server/utils/fuzz_test.go
  • chaoscenter/graphql/server/pkg/chaos_experiment/handler/fuzz_tests/handler_fuzz_test.go
  • chaoscenter/graphql/server/pkg/chaos_experiment_run/handler/fuzz_tests/handler_fuzz_test.go
  • chaoscenter/subscriber/pkg/events/utils_fuzz_test.go
  • chaoscenter/graphql/server/pkg/chaoshub/handler/handler_fuzz_test.go

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions