MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / TestSchemaForMessage_CycleSafe

Function TestSchemaForMessage_CycleSafe

internal/mcp/schema_test.go:50–61  ·  view source on GitHub ↗

TestSchemaForMessage_CycleSafe — google.protobuf.Value references itself via repeated Value (ListValue.values). Before the cycle-guard fix, exposing any tool whose request includes a Struct or Value field would stack-overflow at boot. The visited-set short-circuits and emits an opaque `object`.

(t *testing.T)

Source from the content-addressed store, hash-verified

48// any tool whose request includes a Struct or Value field would stack-overflow
49// at boot. The visited-set short-circuits and emits an opaque `object`.
50func TestSchemaForMessage_CycleSafe(t *testing.T) {
51 // AppData wraps google.protobuf.Struct, which contains a
52 // map<string, Value>, where Value can hold a ListValue of more Values.
53 // That's the exact recursion that would stack-overflow without the guard.
54 app := (&authorizerv1.SignupRequest{}).ProtoReflect().Descriptor().Fields().ByName("app_data")
55 require.NotNil(t, app)
56
57 schema := schemaForField(app, map[protoreflect.FullName]struct{}{})
58 // Doesn't panic / overflow. The deeply-nested Value type collapses to
59 // an opaque object once the cycle is detected.
60 assert.Equal(t, "object", schema.Type)
61}
62
63// TestSchemaForMessage_ScalarOnly walks a request that's purely scalars
64// (no nested message). Profile takes no arguments at all; Session takes

Callers

nothing calls this directly

Calls 3

schemaForFieldFunction · 0.85
DescriptorMethod · 0.45
ProtoReflectMethod · 0.45

Tested by

no test coverage detected