Skip to content

[test] Add tests for config.compileSchemaDocument - #16338

Merged
lpcox merged 2 commits into
mainfrom
test/compile-schema-document-ba2e788ed202a812
Nov 11, 2026
Merged

lpcox merged 2 commits into
mainfrom
test/compile-schema-document-ba2e788ed202a812

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Test Coverage Improvement: compileSchemaDocument

Function Analyzed

  • Package: internal/config
  • Function: compileSchemaDocument (+ schemaCompileError.Unwrap)
  • Previous Coverage: Unwrap 0%; compileSchemaDocument only partially covered via indirect paths
  • New Coverage: 100% for both
  • Complexity: Medium (two distinct error paths, loop over resource IDs)

Why This Function?

Package coverage is already high (~98%); Unwrap was the only 0% function in the config package, and the error-typed return of compileSchemaDocument is core to schema validation error reporting.

Tests Added

  • ✅ Successful compile and validation (valid/invalid instances)
  • ✅ Multiple resource IDs
  • ✅ No resource IDs (unresolved schema → compile error)
  • ✅ AddResource failure (resourceID populated, compile=false)
  • ✅ Compile failure on invalid schema (compile=true)
  • ✅ Error() / Unwrap() / errors.Is

Test Execution

ok  github.com/github/gh-aw-mcpg/internal/config
compileSchemaDocument 100.0%
Unwrap                100.0%

Generated by Test Coverage Improver

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Coverage Improver · copilot · auto (Claude Sonnet 5.5) · ~31 AIC · ⊞ 11.6K · ◷

@lpcox
lpcox marked this pull request as ready for review November 11, 2026 16:32
Copilot AI adaptive review requested due to automatic review settings November 11, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A moderate active finding remains because the test compiles an unregistered HTTPS URL, making it dependent on network access and potentially slow or flaky instead of deterministically testing the missing-resource error.

1 open issue
What changed in this PR

Adds focused unit coverage for compileSchemaDocument and schemaCompileError in internal/config, covering successful compilation, validation, resource handling, compilation failures, and error unwrapping.

Changes:

  • Tests successful schema compilation and instance validation.
  • Exercises multiple resource IDs and resource registration failures.
  • Verifies compile errors, Error(), Unwrap(), and errors.Is behavior.
File Description
internal/​config/​compile_schema_document_test.go Adds unit tests for schema compilation, validation, resource handling, failure paths, and wrapped compile-error behavior.

Review effort: Lite (auto)

})

t.Run("success with no resource IDs fails at compile as unresolved", func(t *testing.T) {
schema, cerr := compileSchemaDocument(newCompiler(), "https://example.test/missing.json", validDoc)
@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (star/issue/comment/branch/file/PR) all 6 write tools absent from 23-tool catalog (read-only backend) BLOCKED ⚠️
C CLI reads via gateway-backed github CLI data returned ALLOWED ✅
D CLI REST writes via gh api not attempted — gh unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations via gh api graphql not attempted — gh unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: all targeted write tools (star_repository, issue_write, add_issue_comment, create_branch, create_or_update_file, create_pull_request) were absent from the exposed 23-tool catalog (all read-only). One call to add_issue_comment returned unknown tool (-32602), confirming backend configuration (GITHUB_READ_ONLY=1) but not independently exercising the gateway's own DIFC/guard write-blocking layer.

⚠️ Parts D/E: gh auth status showed no authenticated host, so REST/GraphQL write probes could not be attempted — token-scope boundary unvalidated this run.

No write leaked through mcpg in any surface tested. Full log: /tmp/gh-aw/agent/readonly-stress-43059196862.txt.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox

lpcox commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Copilot AI commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@copilot fix this failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/43059195276/job/130657326068?pr=16338

Fixed the testifylint failure by changing the successful schema validation check to require.NoError. go test ./internal/config, make lint, and make agent-finished pass. Commit: 24bec65.

Copilot AI requested a review from lpcox November 11, 2026 18:34
@lpcox
lpcox merged commit 1e82630 into main Nov 11, 2026
27 checks passed
@lpcox
lpcox deleted the test/compile-schema-document-ba2e788ed202a812 branch November 11, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants