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

Function TestFrontmatterHashInputSizeLimit

pkg/parser/frontmatter_hash_test.go:259–278  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

257}
258
259func TestFrontmatterHashInputSizeLimit(t *testing.T) {
260 // S-6 compliance: inputs exceeding 1 MiB MUST fail with a deterministic error.
261 oversizedValue := strings.Repeat("a", maxFrontmatterHashInputBytes+1)
262 customReader := func(filePath string) ([]byte, error) {
263 switch filePath {
264 case "/test/workflow.md":
265 return []byte("---\ndescription: " + oversizedValue + "\n---\n\n# Workflow\n"), nil
266 default:
267 return nil, os.ErrNotExist
268 }
269 }
270
271 _, err := ComputeFrontmatterHashFromFileWithReader("/test/workflow.md", nil, customReader)
272 require.Error(t, err, "Should reject oversized normalized frontmatter input")
273 require.EqualError(t, err, "frontmatter hash input exceeds 1048576 bytes after normalization")
274
275 _, err = ComputeFrontmatterHashFromFileWithReader("/test/workflow.md", nil, customReader)
276 require.Error(t, err, "Should return the same deterministic error on repeated calls")
277 require.EqualError(t, err, "frontmatter hash input exceeds 1048576 bytes after normalization")
278}

Callers

nothing calls this directly

Calls 2

ErrorMethod · 0.45

Tested by

no test coverage detected