MCPcopy Create free account
hub / github.com/github/gh-aw / FuzzParseModelIdentifier

Function FuzzParseModelIdentifier

pkg/workflow/model_identifier_fuzz_test.go:22–91  ·  view source on GitHub ↗

FuzzParseModelIdentifier fuzz tests the MAF identifier parser (Section 4.1 of the spec). The fuzzer validates that: 1. The parser never panics on any input. 2. A successfully parsed identifier has a non-empty Base. 3. p.Raw always equals the original input on success. 4. Known-parameter validation

(f *testing.F)

Source from the content-addressed store, hash-verified

20//
21// go test -v -fuzz=FuzzParseModelIdentifier -fuzztime=30s ./pkg/workflow
22func FuzzParseModelIdentifier(f *testing.F) {
23 // Valid bare names.
24 f.Add("sonnet")
25 f.Add("agent")
26 f.Add("gpt-5")
27 f.Add("my_model")
28 f.Add("model.v2")
29
30 // Valid provider-scoped names.
31 f.Add("copilot/gpt-5")
32 f.Add("openai/o3")
33 f.Add("anthropic/claude-opus-4.5")
34 f.Add("google/gemini-pro")
35
36 // Valid glob patterns.
37 f.Add("copilot/*sonnet*")
38 f.Add("copilot/*")
39 f.Add("openai/gpt-*")
40
41 // Valid identifiers with parameters.
42 f.Add("opus?effort=high")
43 f.Add("gpt-5?temperature=0.7")
44 f.Add("openai/o3?effort=low&temperature=0.2")
45 f.Add("sonnet?effort=medium")
46 f.Add("sonnet?temperature=2.0")
47 f.Add("sonnet?temperature=0.0")
48
49 // Edge cases that the parser must handle without panicking.
50 f.Add("")
51 f.Add("a")
52 f.Add("a/b")
53 f.Add("a?b=c")
54
55 // Inputs that should be rejected.
56 f.Add(".hidden")
57 f.Add("-model")
58 f.Add("my model")
59 f.Add("copilot/")
60 f.Add("copilot-/model")
61 f.Add("?effort=high")
62 f.Add("opus?effort=")
63 f.Add("opus?=value")
64 f.Add("opus?effort")
65 f.Add("my@model")
66 f.Add("a:b")
67 f.Add("a\x00b")
68 f.Add("a\nb")
69
70 f.Fuzz(func(t *testing.T, input string) {
71 // Must never panic.
72 p, err := ParseModelIdentifier(input)
73 if err != nil {
74 // Rejected input — nothing further to check.
75 return
76 }
77
78 // A successful parse must preserve the original input.
79 if p.Raw != input {

Callers

nothing calls this directly

Calls 5

ParseModelIdentifierFunction · 0.85
ValidateKnownParamsFunction · 0.85
UnrecognizedParamsFunction · 0.85
AddMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected